guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] GNU Guile branch, wip-rtl-cps, updated. v2.1.0-114-g69e6


From: Noah Lavine
Subject: [Guile-commits] GNU Guile branch, wip-rtl-cps, updated. v2.1.0-114-g69e653e
Date: Thu, 23 May 2013 04:03:46 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Guile".

http://git.savannah.gnu.org/cgit/guile.git/commit/?id=69e653ef032205ea2dd96e0b86ab8785f933348c

The branch, wip-rtl-cps has been updated
  discards  3f7a14a4c6518230774c0df14dde33db15dfb253 (commit)
  discards  af5463addbda9c54a89edcf71ea13608e3749e9e (commit)
  discards  d371575dc32a4f7c8c1c0453c24684916791fc17 (commit)
  discards  be665ec0fe9f28f13d904a96ee32e691f52b1b01 (commit)
  discards  b07be59260bf66dbb762c1660717231d4be3483a (commit)
  discards  f0c06dab524e91c0126a9d222df586de3cd2e020 (commit)
  discards  e49b8f6e09ac7ce81db79f3ad1ab78ee60d738fc (commit)
  discards  847c835017954da66375909d15c9266e0d927abf (commit)
  discards  20b2833f65cd20044aea40ce547873f453eb29ea (commit)
  discards  fb339dacf27d2da3a22d20502f14cffe9dc9431a (commit)
  discards  3a03f6a66c156b712c439cfd93bc18171d7e3793 (commit)
  discards  2463a0c94028fa573f8b7be8b21827b54f5ba191 (commit)
  discards  967985e0cf0fdf7e7aa1061955ed0a21a527333d (commit)
  discards  627636130d246c3953c150067a0f1def34e45a34 (commit)
  discards  c4b9e1845834e866f9ab540cbe8be20f09d33eae (commit)
  discards  680c4ee2172cf97dd40a05df467014f3a86e08c3 (commit)
  discards  0d0808ae3f7390ffb250b9deb6706ad4158cce0e (commit)
  discards  eebd889baa1d7f762e144ad7f9af005946d75273 (commit)
  discards  c6540722c35720d664dd3c294440700746bb6eb1 (commit)
  discards  9be266c32e468e81c72b0affc88da81e6cb9ee1c (commit)
  discards  2aeb4f87c345c709e59f5fe402a9379d15587f1a (commit)
  discards  7e1bb2eabee8417a7d487db3fbf32f5c678e1093 (commit)
  discards  f49400707ce911a6bcaa0d041fa0be131c15e59c (commit)
  discards  d959dae4ee8daca7ee3353865473dc841833433b (commit)
  discards  d01c9173735d87713f9eb66aec1f13d04f9aa32e (commit)
  discards  602113a3cf7f8cc739e3cd9db058d1b4a4b7bfd3 (commit)
  discards  c417e582b6dd48a5704ec18348a05b5b1f2203e6 (commit)
  discards  38ad3632f861e0d8a62d83506ca8f7b8f21d3bf6 (commit)
  discards  58044df2b4309da8c86e32856733acbfbbe1cad5 (commit)
  discards  a7a634a6eb116549268afe22015af16c72fa9f42 (commit)
  discards  a73cfb0f0420e0bba309b1134ee4e6661be36fe6 (commit)
  discards  9b4150779820016deb434136b8ebe9b2fabbf39e (commit)
  discards  37383294d8fcb32cdab21b33b886175e6f018ce3 (commit)
  discards  e2bb02e54fa6e98ab97f30863ccf09cd3fd7254e (commit)
  discards  8f46174e29551dc6755782732f0b11a0a3352a2a (commit)
  discards  b411a8d7f918d9b89502928fdf37b18894ee7aff (commit)
  discards  9c4515c8651ce64ba91cf28da770e938c59a8808 (commit)
  discards  9cc45ec0cd4268d14db11ffd4840a6561fc43c35 (commit)
  discards  d46dcbd600b62d6e57a8bb1ac4907f4443f62e37 (commit)
  discards  ca159cd799998979463d95c16a7a2b3c6df6815d (commit)
  discards  e08e3776d44305668cb882b25e6ee28e23da04b0 (commit)
  discards  eef6081243532bec75c87d66cee09c3306183933 (commit)
  discards  103ccc996ff56d2464c4f643895a2057edbd7c63 (commit)
  discards  bbb9cdd5382df79962ce4d3bb25771331d7890d6 (commit)
  discards  bf51d129e7e557b629ea6568b581e43a261d5c7d (commit)
  discards  03cedbac1b77aae1c9df4f615d1f2dce07ac0bda (commit)
  discards  dd02f3bd546f6a41d75785e8096b31b78e94167f (commit)
  discards  fe0dbf1b0a5227fcd2e2aaa2b2095aeca9d46052 (commit)
  discards  75b2cc9a56d9de6a5ad39db1493813cb917bdc6f (commit)
  discards  e33e246fcf1992811b733da996f7df57a3dc1aa4 (commit)
  discards  d900ea5ee8f55d844191ec5f678101c4c1c64962 (commit)
  discards  a70ffd7d13d62c75e84ecc47cf1962f4f9673ecd (commit)
  discards  b06bfd5104b92dfd0fbfe78efc24e68a9467eb61 (commit)
  discards  ab44a67328af6f77149b5b0a4bfb195ef15a6e34 (commit)
  discards  c1494c22bd5f3ee121c5ee78ab462eecc8ea8964 (commit)
  discards  d537993369918e47d5e7d3eb787f9a85cb4ba0fb (commit)
  discards  fc16925e20c0754e7d823ea5d1809aeb486697fe (commit)
  discards  b4bd81b82001839083dc176b362d620addccd056 (commit)
  discards  690f43d546b37e6572eb926d8c93ba39efd539f4 (commit)
  discards  f05d113a20fdc1b9a5db89103e62d156883f4095 (commit)
  discards  01588507c854cfa89dabd94760cdc25ba4f5978f (commit)
  discards  d559fbdf7e0969c3b43a5c36d539640a4aa8ecec (commit)
  discards  f4c066e9fd8e8f569306567bfa857275355628d8 (commit)
  discards  b8f24db188debc484f1a6ba944461be74bb22a4d (commit)
  discards  edef0333e7e2b5dc2e821d789da1b21503a436bf (commit)
       via  69e653ef032205ea2dd96e0b86ab8785f933348c (commit)
       via  b7a0e32510d294783547af92ac01d07f41d67c64 (commit)
       via  565160d0b906a5deedb75ed65fb55fd69a25d931 (commit)
       via  3b9cb3fced6d4e6370aca357ffbcd04b34cbecbc (commit)
       via  faabd2c9fd64f17fde4e5795ab64ac1f53b6146d (commit)
       via  65e2887f02983c8846d5fbc38c6823dc5db10ac0 (commit)
       via  71e0b716e6bf9e9c034073c01a002ffc2b03a14f (commit)
       via  376611dafdf2d93b296d69a0c904832e75248627 (commit)
       via  bd56dba661850843e85d03bcda7dae2582200659 (commit)
       via  fa3567bd6818a9fe794e8b68242fb0f182285039 (commit)
       via  2a50320c24a8290f6262a69dbc6465989f377df3 (commit)
       via  0c8f13d559e8ad379d0b6fc1ff26fe43f243e013 (commit)
       via  71a43ae7ea77acbad5b75d82098349c8d24e8e83 (commit)
       via  22823ad400b6f6e6469c152f2908bd96ad52e63c (commit)
       via  518f03a79d0383a24d9af9399ffc662a8ebb96bc (commit)
       via  a240d1edf1b314bdda9bdaf2da0ee4a1c7bf8567 (commit)
       via  a451fc92d75ca6691e9682a71f77163a4379fc9f (commit)
       via  cb1859ed3c97146a0e9797532dc950a5c79ab068 (commit)
       via  b57621e62ae2b5c5224b6334785855f1bb349c0c (commit)
       via  1b50c36edef2d8fd0e04fa0bed890546203ddc54 (commit)
       via  14922acd705d62932e095675a2407d7fcd5db1c4 (commit)
       via  169ed53f82bb9d6c5b518a9d6b2ed538f500b240 (commit)
       via  e2eea905032dbd57356154fd6942394fac770c1b (commit)
       via  4f4c8b9a3460a0da22b325fe3b9125e17903688d (commit)
       via  d4fa79fc07edb78eada294c739a5077581c9c832 (commit)
       via  8250248a8aba3b799d096d6cccc07489f8401fcc (commit)
       via  f06f9f9a670d062238da7a1096274d909322993d (commit)
       via  7e653a14720c9d538285e47f3ee1c59f261469c6 (commit)
       via  3388b2909f97eeb2d51116f03c235fedb5ef048c (commit)
       via  9c7ac4455102cde2a5cab4ec47a7034c36e78048 (commit)
       via  a4659be4915160527994bbce6c51f2175f22902a (commit)
       via  e518855430bea39fa784ea0128f976b651dea0a4 (commit)
       via  ebf6f50e82e86da2710bec076e4dfc3f2a7b77a0 (commit)
       via  2724a1bedae60795c409d0c992db4b76902b227c (commit)
       via  9db0d53c8076d2c64fe7ea0c37f1ea7ca7485fe2 (commit)
       via  42cce87a63b1530d1613edb4807777d66e2564e3 (commit)
       via  cc9f2d2ea16b078f16b19a5db48beb19e2a64e03 (commit)
       via  b45297eb7184abcf4abc2bbd285ca694448f5d11 (commit)
       via  d46ac9f5e805f3bb2e924d50293fbd891103af05 (commit)
       via  0d0fef29963519cf3bc77a65525dc227ac9a8423 (commit)
       via  27a81805c441a77f0218ed5e3445995e6c740e5b (commit)
       via  6b5679e39a65f38e025c9eab58faf3f45cf0e374 (commit)
       via  3bfb859e9fd08f168062985c870f2d424bc114cf (commit)
       via  2bb1ab70e29c7d74b596cc7c36d622de681f996c (commit)
       via  23e20c4ef6ad2bc0214f6d0c473256f741c4f399 (commit)
       via  2dca054650731e6de1b9a5e397c7bd681be1813d (commit)
       via  1b38955510fb5a4669d00f80042882887c6302ef (commit)
       via  793d210958308a2373acfba462b4b77a8a48af02 (commit)
       via  dbe241fcce7b6b411755ed54dad400ba5f070dd0 (commit)
       via  9eb1082917db07fcf460c0a9b94d4b62421cd048 (commit)
       via  908aa266c4335807f804a789633b79610a0565e8 (commit)
       via  018b17b0d7004cc03b7760a471dc7ab91930639b (commit)
       via  6f6fa2f9e5625264a7dc24bc83f7f3574dc25a50 (commit)
       via  c8c72d779ce244473edfa7917ac1dc5badd24f0b (commit)
       via  0dc7dc27fdbb0079f9d36336965f85231b5bcb42 (commit)
       via  7e1770fcf1e6cc1d72e02d22f558fdd44a909ed1 (commit)
       via  296ba392fde0b3c3e9eb68168beadb5157fe3206 (commit)
       via  552110a1f239925bd481067dfd02fb5bc06d859a (commit)
       via  d14e903c59862cd4dab6a96fd8963387986f5276 (commit)
       via  fe4589b54f9b116d589f35972e093a3de9c5e802 (commit)
       via  36192fad0d6dffd29a8f7757f9491a85e477f67c (commit)
       via  17bf887174a43b35c28e157f1db281ade964f05e (commit)
       via  67759d2f98d7ca1aedb8e73ab6958ae9687c2767 (commit)
       via  d273a31b957eeef14b1e68e93aec45e78449e125 (commit)
       via  ca1bc7ea9d5b24755365e01a7b8beeca565e0e7b (commit)
       via  bf2321bfd43cbe49d481f1b3c40f26156375a3ae (commit)
       via  f1de620f2ca81adca9f9d3cce5b8497cd81e5360 (commit)
       via  bc7e981d1f63c93ad6cabeb5a555c95612fb8632 (commit)
       via  424b2a5f27dbd072f5820c4da27a6c99ca8b7fd3 (commit)
       via  035baf41e24fb106e26af22ca30b36bc9c91f38a (commit)
       via  d9da66f0d9442f7e0d1b50dac798f7e4df4fa4e4 (commit)
       via  9a3b644be9b567c40b3a0bfe07c41554ad439f47 (commit)
       via  76bbaf2fc0f28a187fc5127033ac259d427b6797 (commit)
       via  8a3e07c371538eefd066bb6d6d884a1d50782e0c (commit)
       via  fd899af33d84a1263f68c066c2bbb612cdba9606 (commit)
       via  825ca5201fa5584a8912d790ce9d0b9183e4756f (commit)
       via  907e5d36940e457cf3f62e60b453252a4a9b24eb (commit)
       via  96e97fb222a7abf5e655e4139ca828b8cc5c2cb0 (commit)
       via  82dde214166de8a1d58d2f48c324978136cf7abe (commit)
       via  49460b177e6bf2b7cd301c3542d99122e96afac9 (commit)
       via  4c5969aa9f0257e6d7901e107ffd63afe89aef31 (commit)
       via  21ce20e5f809c021567ff0c86243b1e3a35209c3 (commit)
       via  40c122fe9f45267fd8258b98fef961fee4753ebf (commit)
       via  320f390856fc155f5efc343aac2b9ad9e6fe4f3c (commit)
       via  e770d89c839f321efc819ac925f6807623cbbceb (commit)
       via  e82ce87fb95ff3c26f5906b68b732afbe71ff4fd (commit)
       via  db6e47794757ce055ea80c35f027cd9928868b56 (commit)
       via  44e5b0b6764b9eb4300e27c6d41065783504772e (commit)
       via  bf70050bec92f8e3e24bc21b6d399618a4d06521 (commit)
       via  49f90dd01649b356014fed0bdc3d9d5028a0f218 (commit)
       via  70c4e6787b19fbf130706f90614a164780c70feb (commit)
       via  a8d4671006ad6627ef92194054c51e28183f791c (commit)
       via  a24e55fdd0ecc4ee3a31b8236d6fa66b868c6d04 (commit)
       via  41d7621ab541a7977e15401fcbc441c624b0eff6 (commit)
       via  be75c01efe6f11015db65c5aeb0a71681b496100 (commit)
       via  e6f107f5ae5be11b619762b8e008313f51a33f90 (commit)
       via  e865524c6a37fcfd01f10290741a85dffd16c83f (commit)
       via  175b2c42b18bf510377df4d42c8ccfa629d54aee (commit)
       via  a000b510a9c4b6943930b1e30ad22513671981c1 (commit)
       via  bed8e4bcfe1ea4665e0bc19a20d7e4c3523111f0 (commit)
       via  9c18030fb0974c618c0a24a98b3cabae206387c9 (commit)
       via  ac86a0da65fa06fce462301a20c94fbba360f5fb (commit)
       via  1102f1da7bf47fbee9671a40e6d947fcece327d3 (commit)
       via  c10992a55450f4ea60bd54bf4b205ca9495ecf26 (commit)
       via  a580a843111a5785f7936a8198eebfb1ce854b8c (commit)
       via  ae10f67435c9cb513e0fa2afa83b00380a6ed793 (commit)
       via  1b891621c7a18c658a03eba0213845cbdb50ffee (commit)
       via  511e94c56fbef422ed8ea4984461a06dbb676d0c (commit)
       via  a2a2bf7e2c0d840bf84d1edc8e81fe30df795f6b (commit)
       via  ed094734e59d1b2bbf30f2ab17b21377b5dd15fe (commit)
       via  8ba3df917b47c33161de1c225757636ddb6ba7ba (commit)
       via  c072e1bc8bed5f2dba94a1ee640a875d49e2febb (commit)
       via  099eb548ad27bb8b54adaf1116e72c45130122ee (commit)
       via  60827e5df16151f2ca77b2dfd4617e23604da6f1 (commit)
       via  f6f4feb0a2222efcb297e634603621126542e63f (commit)
       via  f5b2eea6a39507ecf6a8ecc62cc1c796c45c2d1d (commit)
       via  3f315b64332a61535846dc87284e091bada747e5 (commit)
       via  f480a98e9ac784e24e418ff307b67c22568a682e (commit)
       via  dac5e6491b215f8d70bc8328639b4c72cb7cd565 (commit)
       via  7f74dcb4a5439bb2247875f458b5f0a20710af07 (commit)
       via  800c094382c2e506c46c6e98e7b867d3df2e066f (commit)
       via  039300a1ebee116082d50d61e6b3aeafc8a741ec (commit)
       via  cfeb9130bb5d1b512279bbdce0e9211f85d359f6 (commit)
       via  3e78acd978a437c0aa5f5405daca59f1fb648516 (commit)
       via  fff92ff309075ed599a07a2e9378a0ed587ce073 (commit)
       via  486a456d4d456f712ca9bb7b63cd58aadbaef536 (commit)
       via  47ad34fad6d79c93e1d1a213641c747ba05a3ef6 (commit)
       via  9a5b6f6edaf33282c29add729a9d55527abd5517 (commit)
       via  11f80955e8a218ba0bfddc206b79a6916705eae8 (commit)
       via  4e7d48a04bb9500afff4d44e9bc9e03c536f12f8 (commit)
       via  14f2e4706863b4dafc55c7b7ff8682634f77a96e (commit)
       via  40e2a31d8710eddbf564fa11d14a6af57e504448 (commit)
       via  32cec09d136060e02dfa28d65f2cb19028706652 (commit)
       via  e67cea4214959663ff103b19cea0db9d6c869a9e (commit)
       via  b1b1cbcb78a7b4e2777ab596ae24d10d28aef8fb (commit)
       via  82352e01ff33dfe4d554f1f8d3ec55940ed2bc43 (commit)
       via  f841b26d847edf2d8196c3c21c090f50cf3a614f (commit)
       via  51607806ec2f2fbe4e4739c3ed599a36121e5d42 (commit)
       via  3c8f2ae958f96f16ffcbb74e0b022bd9999ecb03 (commit)
       via  22c76fd82288fee2cb0bb744c2e28d1be42204de (commit)
       via  7ca88a403f1a81e7ab48f2b5a6d5d07ed4b5ef9b (commit)
       via  7520a9b95d2661cf40f6c1bf8be79f38ca632516 (commit)
       via  7f3be1db9949b0566d3a2cb6bd9d0e84287bbb0a (commit)
       via  eed0d26cc0668a309b610113554be5df8dfb32e9 (commit)
       via  e0886e0780fc1f3ce1c80d0692c11adf3b68f682 (commit)
       via  254d313a21f06739930032062678ff5360d248fd (commit)
       via  7099eec4fb93d74beace4cef20a93c1e4f0aee5f (commit)
       via  3ace9a8e4e1de7082ceec4aea0813a6adaa913bf (commit)
       via  b6e374e535597448cb09588300d76b5d270d5d3a (commit)
       via  3ed8d953f8d0da8ed82fe939ce48a563d7abe19b (commit)
       via  7f6c3f8f0012e916469fa6c50b44c621ebdc89ac (commit)
       via  e1966d0e214b0967c19da71b235196adb057d2b5 (commit)
       via  9a334eb3ab6bbb250d9c0f559b82d1c97f5eb21a (commit)
       via  bc3901092dc777d832862862e606ae2ddeb6f2f8 (commit)
       via  7d39b48875475b2d206789cb9b6486b79c7be55d (commit)
       via  48ffc52cc96fc0665183d9a9e3f68e7e031487f4 (commit)
       via  a71e79c3e5a5c366bb9ec218ee537441b8e5949a (commit)
       via  3e5a164ac3d93a1a43c0e81842d0583fe0031b84 (commit)
       via  a16d4e82e949954805bf2cd42cfbb519fcf4012d (commit)
       via  c608e1aafae347dc52cda70aa9379e9b6803b5e6 (commit)
       via  9c90a81bb5beafdf4e15847a59a967c70f00c400 (commit)
       via  4ad329cbcaeef603d047df5dd226fb17f0b81483 (commit)
       via  47ed3ca43aa32acf1550c0ff9696b1b51f43e236 (commit)
       via  004094d378182d8343398c0bec817114c06ea933 (commit)
       via  66750b78c7f67e91d1e01a4926e2e85a12f2b16a (commit)
       via  3f1362adb5203b95079200520357bff36c3a6672 (commit)
       via  a24cda1d26e09ddddb2cfe6633d7fee7a1b66d35 (commit)
       via  d09b201d59f55f692323f82866512cba2cb29c76 (commit)
       via  ab1ca17986ee758b7ec4088bf3f6a596872b1677 (commit)
       via  b5159a471a1acbe1ad08ee5365d123912fcc607d (commit)
       via  55e26a49dbc5fa7ccbf218305d88b0b37db4db3f (commit)
       via  d888b531681c8528a2daafe0bea70c0a42313da6 (commit)
       via  96965a6ecb04b5380fd6d618e70d64dec3ac37be (commit)
       via  e501f2111e0d5a8bc037cfe3df4e6ba0655285d5 (commit)
       via  4b76acfa38d6939241e0b4cfdbbc46e8aac13e1a (commit)
       via  4a1cdc9d5d643d05fa7a18febc7c12070f3ef6d9 (commit)
       via  cdd3d6c9f423d5b95f05193fe3c27d50b56957e9 (commit)
       via  45c0878b8665182f06a917e391169031c1dc7db6 (commit)
       via  0426b3f8f8036364aca13c24ef769283937faa3d (commit)
       via  71539c1cd3bf16dfdb87dc6c0c5f4238ebf8dcd9 (commit)
       via  412053922501e2e9cac7fc0c1b91de8fc3aa375a (commit)
       via  c3e3ef6eb6d1487d342389b202b0b00f9385de6a (commit)
       via  3220b080498580586726313ec63db9eaf68334d8 (commit)
       via  0d7f3a6d957a3129dc0aa203abc1b6adc82db295 (commit)
       via  51a1763f6596d594ebd774e7c3fd9138e6f4d507 (commit)
       via  9a68d7b388c610cdbc5689ae9cbadb70ee311f67 (commit)
       via  75a1b26c5d06e791afce10be9b1ab4e5272e45b4 (commit)
       via  7290de89fb5bf755e2520bd01e977dc132c50c4b (commit)
       via  72e2b5923a15f49fd7f7706fe35dfc1157a41bb5 (commit)
       via  9a31a54561b859dfbaca4f4523252a76adb56386 (commit)
       via  e00793d7a986053976c088f4aa4088c4d648825d (commit)
       via  1fa89aaf6191dfe24e7494726ce37b698736103f (commit)
       via  1ee237d9a159e0e9a995ecb9fea24e1d39a7c5e1 (commit)
       via  8a2b596579185cd0f4d35da478f447e529d81a80 (commit)
       via  187fa0b9e7ff9b2d6204517a9daa9009245c7511 (commit)
       via  05d7f76296dc9fa21e0abd1ce6105a042905f48e (commit)
       via  21bbe22a14a75fab54a5a8563fad63851a18fee3 (commit)
       via  337edc591ffd8f8ec4176b0112ad10da29818141 (commit)
       via  e459855936262b4bddaebd87a75abdc065799be2 (commit)
       via  663780bb1c881947b6e4f00c456b2b367701982d (commit)
       via  369294866dd7ee01ebf821df2a119ea55b1e68fd (commit)
       via  1e051065628a7f1bd4398fcc11cd181f86084629 (commit)
       via  de2bc673bba931a70e3b96336cab6512a47541fe (commit)
       via  786ab4258fbf605f46287da5e7550d3ab4b68589 (commit)
       via  2f13a46672a347be0f7bb1b360a213f6d6ce0288 (commit)
       via  3b80c3585221a899c9a6b87e742d267655bb0abc (commit)
       via  47f2bce5ae332c274270882c259776b8e4ea12f7 (commit)
       via  86cf4773ff94a128247d484e6d69786869f41ebc (commit)
       via  b05257b9232e2ee631c28b15cace5981c4927446 (commit)
       via  beac49b8e129b28902f4b600e15aa3b92c9ce7fd (commit)
       via  df3d365a99311ecfe921d1dfd1848ff65112e572 (commit)
       via  7e7c6f6a937005b08fffd5aeccdf992459b07137 (commit)
       via  7bfbd2935fa812a0581df5b78c1a3b9836065f39 (commit)
       via  0ddf484d3eeff9238cb4bf6f89d461748f42cb1c (commit)
       via  c33ecf96a41979be0af1d56a7e12ad7c1196f12b (commit)
       via  4702deb424633ad02c495c01d950b973c0ead8ea (commit)
       via  465ff50245e0f5deb26612ac7401b51c415deeb0 (commit)
       via  2a7d614cc0bc902895cdb873590e8a24cf680368 (commit)
       via  8d6e3dd83a09f35a18774baa696ba443aa379cbb (commit)
       via  07b390d5827da2f46f57e4650167920fb792ebc9 (commit)
       via  06589f5c229c3ce4dd2cb627c90ef4372dd0a571 (commit)
       via  4a0821a8d5cfff50fef8c119a0d76355b6126009 (commit)
       via  10d278fde5dcd8033fe1209657aa58ce792b9b83 (commit)
       via  26d148066f9cb20e395a7dc4fefdf2e2ef0b2fb0 (commit)
       via  579127cce488ce208d62e68e679e34fbbdc17367 (commit)
       via  10b8cf1ebdba6989e8c9b23838d2f20d6cb7d60b (commit)
       via  82ab673ceafa3174d9e5f8dfec08221ba69addba (commit)
       via  80b809f114e9f3978aa6571affd343f34732fb94 (commit)
       via  50d08cd8943dd54762d76746d5eec53af178eeae (commit)
       via  ed4aa26489d33c22bcdbce2bb037a87df41bef16 (commit)
       via  8a177d316c0062afe74f9a761ef460e297435e59 (commit)
       via  8cd109bf0a10e37c26bf476fed81a0d4282d13c6 (commit)
       via  ffc8eca636a8e9311d35c9adba2fc80476ab11ca (commit)
       via  c548da6949fef565dd1267afa5bbf2c21edda366 (commit)
       via  41502bd00f12a6bce97484d33f5519e97a04cf2a (commit)
       via  d291d7990d72b5cb8a18b20e524e1c8324297e92 (commit)
       via  65ad02b96d4118970406b1474aa00bbe801aa61a (commit)
       via  59b0f9d7635ea7e272e2976ab69764a570d7f6ff (commit)
       via  5bb40f9df02c3395b198f254fdd43e7468b5ceee (commit)
       via  570fdeceacaad7f6e928123f40e8bb5f72677dcb (commit)
       via  11ed42771dec06626457eae58f2f334df1397f72 (commit)
       via  f28885f4957882c4d96bdfee11d26cd265539aac (commit)
       via  45417ab1066b3f7f65ff4ff4f6ca2733c75bd521 (commit)
       via  86fafc440220b0ab1d76439e89ac8114a9c7660d (commit)
       via  fbac7c6113056bc6ee85996b10bdc08325c742a5 (commit)
       via  e8a57fb052c4d9c27681183bd0cf2be31142d58a (commit)
       via  43c2a48323803e9aae41ba896ce6b6a0067343ad (commit)
       via  c5c7c1146f2488f92b11b1edbe36fa99ffdf2771 (commit)
       via  6cfdc6b87881a592b7ad99db8d9ea0ee13a4101b (commit)
       via  2bb7a730137013d2cc931e3b5932f6235d76e1e1 (commit)
       via  8fe4c4eccbd6fcd5e26d955cc3b59aef60f561ee (commit)
       via  4215ea75a525a848ce9d73fad9c03983e8b3cd0d (commit)
       via  797b2aa69aeb7db607250bad83d31a31f8f4d1c7 (commit)
       via  c52ce75a1f87e72d675fc5a6ad95ef26dd517e10 (commit)
       via  14ae4725ab5cdfc334786012c0b4fdacc2851be2 (commit)
       via  edb6de0becea3a52a4e5e3fa73a090928f0cbd61 (commit)
       via  8edab37f17cd60cf6986da822dfbdad6067aef66 (commit)
       via  ddb717423619cb2c36fb798dc12552b70cd9b0ad (commit)
       via  687a87bf012f0c0afa79dd9bebf7d173d1243880 (commit)
       via  4400266478b4a477c6747f9eed38f7c6021491d8 (commit)
       via  c8248c8ed5459991e7d2d6d8f20f652295c19514 (commit)
       via  1d64b4edb9da4011ad06c0fab1c6225ec20b0876 (commit)
       via  8150dfa1f2f84d151ced5f723dc69ce0cae1cd32 (commit)
       via  a9ea4f909b9970c755b0a7c4cd9da907e66496fc (commit)
       via  e5029c585382471f81717f8e1539854d90579512 (commit)
       via  5f24f1b53ed2c1746670ae8828a05cc7b63354e8 (commit)
       via  1ea37620c2c1794f7685b312d2530676a078ada7 (commit)
       via  982377849029f2840ebb105cda49390fecca4fe4 (commit)
       via  b1c46fd30a4615b4ab534d6bd824a81e3f536660 (commit)
       via  2e08ff38b735020e8ed5403acb637e6041d3d743 (commit)
       via  dc8712611597c6d5be918a69b0ce719e0675f6fe (commit)
       via  01b83dbd1a11735519b7d6ca7b02006b45861c9c (commit)
       via  f361bb937aed7b26a18580c78e66657ed44be294 (commit)
       via  912f5f34458fd6998b129e65685adbaf44356860 (commit)
       via  de2811cc41e86f8f558cfe99172a1987cbcad47a (commit)
       via  8ae26afefee947c71314733c419519fb616bf36d (commit)
       via  dbab8aaacaa7ce4d1d3db09d422615b6fcd6724f (commit)
       via  dfd1d3b144d97522b2a4e82dc583a43e0b4f8b93 (commit)
       via  24475b860b02880b1cfdf4e03f9659a8af09eb72 (commit)
       via  7f34acd8a48198c7fec2daf8d2f4161eaa9963ec (commit)
       via  1eb6a33a30ea27f97fc401a25a3014e10e3c6f98 (commit)
       via  e08a12b5356c20ed0418bcaee136eb3632c5616f (commit)
       via  a285b18ca820e089e2e5d02f8ed07a1e341dffc3 (commit)
       via  d2df3950a905f7acab70633717beddfd90455b68 (commit)
       via  b5870f25ad70dc70df99f69ff2652d73ec07343c (commit)
       via  428f9e95fccb7105f00d22e80312e9f5a7a263a4 (commit)
       via  ccd0ae1fbb1c8c942a89bf84272377b341739e0f (commit)
       via  988ca6b212fce6d9419d1ffce8f115425ade3a9f (commit)
       via  a4b4fbbdaa3542e35ea436179200d071b57ff1ca (commit)
       via  e9381f58d1b0c9d8882328efecf938b45817e3dd (commit)
       via  cfe24bc4deef6f52ad3e07ffc513160890db4ff3 (commit)
       via  84dfde82ae8f6ec247c1c147c1e2ae50b207bad9 (commit)
       via  94c53e0601c3fb4a4dcd6d3bd602347a8253c167 (commit)
       via  aa59904eaec70c95fa95960f98ba9cbc62010e8d (commit)
       via  b7548cd2dc4ead3c0ad3d2fb5c9fc43d54e6ce8d (commit)
       via  6ab4de612510b7c8668f0b50388258392f25b157 (commit)
       via  d3c88f18261b78f1ca9903f2f179b7f812288e1c (commit)
       via  7dfcaf2616f6a6a712aa8cbb454aca00419db08f (commit)
       via  3baf6e8b0577c32610cc6ba97af209185c16845a (commit)
       via  b0dbbacbe40fc8aa0b057101f84aed96ac4bea07 (commit)
       via  ce09e6bd0f2903566c14b4edf2659c19f2eb95b1 (commit)
       via  14b59d61028c94c8072f2f171fbc987102ad714d (commit)
       via  629987edfb1d03bcbdb6bf7f15d1ec0ff928e6f8 (commit)
       via  ba59471eeeeb6738f87e1c9c4050ce4698a7c9d8 (commit)
       via  eac7a5d03909291e62c671ead3d1c6a0ff84d4f0 (commit)
       via  44e30ef241e342406d69c7d9c480c630d6106612 (commit)
       via  cdd125e8d475a6d02606322fb4c54dc76bbc8072 (commit)
       via  4fd38267bca2987c6340c019a498ea6bacc6c5ec (commit)
       via  1adba49ab20ac283ca62963f115910f1cf7b63ad (commit)
       via  09b204d38756f0fa9ab4319874c8ce2838488dd0 (commit)
       via  7e369c38993cc7cf4063a6cadc8496552abf323d (commit)
       via  4c187d46d40aff1601f38675c11f92a73a13a7c9 (commit)
       via  19113f1ca7a747de06d7b43c6c1eca4cd58d05e5 (commit)
       via  9ddf06dceee3a2bf5480a3e261ec01aaa91a1f67 (commit)
       via  929d11b2c1e1060a51bf7e395ab0ddd48e599144 (commit)
       via  aab9d46c83c2ad03abb0a2dc000167e552de2c29 (commit)
       via  d0ecf8eb9e154dcc253b1ea302d67d41bcc4ee36 (commit)
       via  8d48877d2cacebeb1352404b0e2514a60416c8a4 (commit)
       via  83dce818ec912def820808c059ee6f9c3801585e (commit)
       via  7f893030abaf49711f948d76f124e18bfa9e4181 (commit)
       via  1b787ef9ec3a08f12d7b46403f4d508e583499a2 (commit)
       via  e20cec744fad8299afd9bbb6ac49505b15437618 (commit)
       via  6db7ee7b3ae8a7dbd6dc194921024287bed40a0a (commit)
       via  e6a7a86d7ec9fe1dcb77686ca549766e1641a961 (commit)
       via  0c8a2c380d705a5113f01d5f8e042897969ca844 (commit)
       via  cba521fe42484b6689769a484408de56545d8678 (commit)
       via  a2dead1b0fb6523598e3acbbe91127eaf47fe98c (commit)
       via  f57ea23ac8e1436f37ceeda3ea8625243c20e645 (commit)
       via  29ace173b170a5d77e6becb30fb1d9f253a373d5 (commit)
       via  69b6da07c386446d16a11cc41cb64b486199413c (commit)
       via  994d87be35769480b04c9f96085a7a0b41040c9d (commit)
       via  183d2ace576710079a2bcf2a8bfcbc39b7d9becc (commit)
       via  01b69e79f617db3c68b117512b6fe29978ba0ebb (commit)
       via  0f595d7d1d57b12036bef801538163d3773567c3 (commit)
       via  764246cfbbfff21b3127fff500e972e1dc4314e3 (commit)
       via  8dd01861a9a0331b912a1ae6310e64eb6b47c29c (commit)
       via  b8d8f8b9292a4755d2c63bc7a955d75d96eb05e0 (commit)
       via  5ccc3764b3e17a328dad515d9a74123653f1fef9 (commit)
       via  aacc689677316ebb1ea45bb8fb22f921ebaf97d5 (commit)
       via  a5d8f98c60344548f0b6a70828b95f2b2e1f7553 (commit)
       via  b946e08a6ae6e73bda1f76017fcb75f41cd4b288 (commit)
       via  9130ec74cf55a2531a364ef16b6608489b583f16 (commit)
       via  cc2948aa3189b7bd29c23e7a93ccb1217a1b4eff (commit)
       via  4124994771e8fe54557a7af85e2af9c68e6ea2a3 (commit)
       via  94a7029acf5ca59615bb486b1e9e196e572df6f0 (commit)
       via  be6a36a05d79662243c384212032783cffab5316 (commit)
       via  587f4edd3947880fb0235f84cc18b62f133a9255 (commit)
       via  3ec19a7884ba789a9b4f91f61415aa4b84642690 (commit)
       via  444b26f739d88ab410d561f1abda67b3d6c0f491 (commit)
       via  08904661a2b1c6d461b2f5abfe3226a4023453fb (commit)
       via  c085589b1c34fa88d28c23cb5e3659fecdb09f33 (commit)
       via  72ad03fcbddb3b87de5577b7225f6dc6f892ac93 (commit)
       via  1746b8ffdba174fde4a8e293309a18d112750588 (commit)
       via  7a17979ea4ae769c60ca4ca291cca877701c08e1 (commit)
       via  c21939bc247e2e36a5d698c60ba4a03cd3bbaf38 (commit)
       via  4bab7f01be8a1ce321f1e30235e1077f1ea0804c (commit)
       via  65fa3923060dd66b166fd858bcd6f462f37ee8c0 (commit)
       via  eaf21539d4afb8df5d1b549215fd397b23004947 (commit)
       via  99d1843e2a06f422cbe349804a67d2972c4dedd9 (commit)
       via  f5ea559aa04186534ea6771e3c15d5201fe85c67 (commit)
       via  0e4288608896eeda4ad6f18cfe91d45be7c87c35 (commit)
       via  90f51aba0d2b28ac4819f8800f2dcf8d67edbd28 (commit)
       via  e716f4410fb3f6c614def5a9b33a39185f637002 (commit)
       via  5a4a4454c5302ed511eafde5a7759ebf00fbee17 (commit)
       via  854ada4f1af8d72859b77e8764729f3cca45460a (commit)
       via  0725031fe3a95d4e61e76ffa7aa1c79d4bebb00f (commit)
       via  9b6316eabcd3438ca01d1bf7269702af24c3ec5f (commit)
       via  90a162323251bfda86d82b2a3c0c7b12ce8a0bb7 (commit)
       via  6f160a6e99a68347d11864d4a9bf15da851c9202 (commit)
       via  84ebfef4e69130288d68d68c9e872402aa91363d (commit)
       via  3dac6181c18508a194f240d633c8c3f7304adb3f (commit)
       via  af07e10429c1513c2348289888b240926264b32b (commit)
       via  9b977c836bf147d386944c401113aba32776fa68 (commit)
       via  739941679c2c7dc36c29c30aff7d4c1b436ba773 (commit)
       via  118ff892be199f0af359d1b027645d4783a364ec (commit)
       via  336c921146957a7416bc1717289a01f1b556ad82 (commit)
       via  18cd9aff9429c99ffae34448507f9b468e20e06f (commit)
       via  3330f00f54649cdd0914b6ff03c7b7bbc38ffa8d (commit)
       via  3d2b2676e3fc0a5b243b8a4188d07bba1b4b40a4 (commit)
       via  91c763ee3f195dc0e26339608da01250d6924009 (commit)
       via  85edd670f5674bd4c25547936b1faf61e2d7a397 (commit)
       via  8598dd8d28d16fe1ec92dfc49f6517992f1598ec (commit)
       via  d21537efb4a0edea30a7ab801909207d4bb69030 (commit)
       via  564f5e70543f771e1e7c5aa57cee6f8b8d20c9ed (commit)
       via  30c3dac7a671cfdfadf8452c4ff9117fc0a5b8c0 (commit)
       via  5ad85ba15f901163190b365ddd744db22bbbfc42 (commit)
       via  10a467f39887b722cb4cffa1a22c94a7b1e37bbc (commit)
       via  1d14478ffb2e7b2f9790d34f8c03376abc0675f8 (commit)
       via  ff95e1022586f40276ea37c0d5b05a370b327be6 (commit)
       via  9cdc5cdbe6c3cdc4ae649016b8673cf038b5294e (commit)
       via  d4cab459d3a479af12ad2bb37ebbead0d6806802 (commit)
       via  d4124ac5cecb017f949ecfc10095645c3e79d989 (commit)
       via  3a3bea729fa25d1351d070160a65db5e9445ebc1 (commit)
       via  7facc08a80149bae4f973c07b30b56e3ae945be7 (commit)
       via  bcc7e238c9c88221752ebfe09c62a149d40cbe08 (commit)
       via  e2c6bf3866d1186c60bacfbd4fe5037087ee5e3f (commit)
       via  8364ae3fac3645ad3e8b53a2c4faeeed162ea0ea (commit)
       via  180ac9d7b0bac97bdead2813a1b0b23d19002c3e (commit)
       via  ceb7f9cc126f50e0cc8956b80ac5d111580b23c8 (commit)
       via  32e3c505c37ede7f096239574c3ac46206bf0cef (commit)
       via  419c8736243e78a60020f5215ab223af6e9b7bb1 (commit)
       via  e10c250928bc6c4116d6344616d39f3c52edc36b (commit)
       via  1260fd0b2c4ce1d0d7e7b17df924c245f67f9058 (commit)
       via  7e0f26eb0d5a9316daad680f62168beffd050632 (commit)
       via  b2cb557d75e4daf8c7c8cd43313f4cc51d9a3f1b (commit)
       via  a8fa310b0493cd2e88a7d7f08b1ee3183a81b455 (commit)
       via  ac28db6db12dbb7c43e3e2207d9607989d65bc6b (commit)
       via  aac01de63dfb44a442df8ae6920ee431ba81780e (commit)
       via  90baf8cdfe8ce356ee4720a012e0deb5a2cb5818 (commit)
       via  a14b6e18259bcc860ecc7bd3bf320d3adca9ea47 (commit)
       via  1488753a66d499cab55edee8ee7e2b2ea5a64717 (commit)
       via  bb0615d0157facb67ee1489a9764866dcd97eb20 (commit)
       via  3e31e75a462fc05f425b887105ccd6607a56ca3b (commit)
       via  2b6fcf5b1f6f3cf8d94cada4f00885b275f1a7c5 (commit)
       via  25645a0ac9158916667588b76cd541ee9dc05132 (commit)
       via  b34e25359aad4a08e15de8c5a150ebcff55ff7c1 (commit)
       via  13ff681c33a0ff6ff6004d44126697f6dea3ec73 (commit)
       via  ed7c4a5d777bcff78512f1f1f9f2847ade90af11 (commit)
       via  4ff2133aa16a29347149ff04225fb4649256e9c9 (commit)
       via  e70b663c24420093f98ce6147178be5ef92655ba (commit)
       via  a3df9ad9e6be7d5fbc566a10bc9ba035a2e38f31 (commit)

This update added new revisions after undoing existing revisions.  That is
to say, the old revision is not a strict subset of the new revision.  This
situation occurs when you --force push a change and generate a repository
containing something like this:

 * -- * -- B -- O -- O -- O (3f7a14a4c6518230774c0df14dde33db15dfb253)
            \
             N -- N -- N (69e653ef032205ea2dd96e0b86ab8785f933348c)

When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 69e653ef032205ea2dd96e0b86ab8785f933348c
Author: Noah Lavine <address@hidden>
Date:   Thu May 23 00:00:01 2013 -0400

    Adjust to RTL Change
    
    * module/language/cps/compile-rtl.scm (generate-rtl): add argument to
      call to `begin-program'.

commit b7a0e32510d294783547af92ac01d07f41d67c64
Author: Noah Lavine <address@hidden>
Date:   Sun May 5 01:11:25 2013 -0400

    Module References in CPS
    
    * module/language/cps.scm: new CPS data type 'module-var' lets us
      describe references to module variables; replaces old 'toplevel-var'.
    * module/language/tree-il/compile-cps.scm: generate module-vars.
    * module/language/cps/compile-rtl.scm: generate code for module-vars.
    * test-suite/tests/cps.test: test module-refs.
    * module/language/cps/annotate.scm: adjust.

commit 565160d0b906a5deedb75ed65fb55fd69a25d931
Author: Noah Lavine <address@hidden>
Date:   Thu Apr 4 13:00:04 2013 -0400

    More CPS Tests
    
    * test-suite/tests/cps.test: test calls better, and closure sets.

commit 3b9cb3fced6d4e6370aca357ffbcd04b34cbecbc
Author: Noah Lavine <address@hidden>
Date:   Wed Apr 3 18:08:05 2013 -0400

    Clean-ups in CPS compiler
    
    * module/language/cps/compile-rtl.scm: merge some if statements into the
      surrounding (match ...).

commit faabd2c9fd64f17fde4e5795ab64ac1f53b6146d
Author: Noah Lavine <address@hidden(none)>
Date:   Fri Mar 8 17:50:22 2013 -0500

    CPS Annotator Handles Letrec
    
    * module/language/cps/annotate.scm: handle letrec and allow #f
      as an annotator.

commit 65e2887f02983c8846d5fbc38c6823dc5db10ac0
Author: Noah Lavine <address@hidden(none)>
Date:   Fri Mar 8 17:48:58 2013 -0500

    Closure Conversion in CPS
    
    * module/language/cps/closure-conversion.scm: implement closure
      conversion.
    * module/language/cps.scm: comment about closure conversion.
    * module/language/cps/compile-rtl.scm: compile closures.
    * test-suite/tests/cps.test: test closures.

commit 71e0b716e6bf9e9c034073c01a002ffc2b03a14f
Author: Noah Lavine <address@hidden(none)>
Date:   Thu Mar 7 17:10:47 2013 -0500

    Handle lambdas in tree-il->cps
    
    * module/language/tree-il/compile-cps.scm: turn a lambda form into a
      letrec, except for the outermost lambda.
    * test-suite/tests/cps.test: adjust.

commit 376611dafdf2d93b296d69a0c904832e75248627
Author: Noah Lavine <address@hidden>
Date:   Sat Feb 23 11:53:46 2013 -0500

    Allocate Registers and Labels Separately
    
    * module/language/cps/allocate.scm: split allocate-registers-and-labels
      into allocate-registers and allocate-labels.
    * module/language/cps/compile-rtl.scm: adjust.

commit bd56dba661850843e85d03bcda7dae2582200659
Author: Noah Lavine <address@hidden>
Date:   Wed Feb 20 22:03:27 2013 -0500

    CPS Annotator Infrastructure
    
    * module/language/cps/annotate.scm: new function for annotating CPS for
      easy viewing.
    * module/language/cps/allocate.scm: use annotation infrastructure.

commit fa3567bd6818a9fe794e8b68242fb0f182285039
Author: Noah Lavine <address@hidden>
Date:   Wed Feb 20 13:12:37 2013 -0500

    Split (language cps compile-rtl)
    
    * module/language/cps/compile-rtl.scm: move
      allocate-registers-and-labels to a new module.
    * module/language/cps/allocate.scm: new module for allocation.
    * module/language/cps/spec.scm: removed for redundancy.
    * test-suite/tests/cps.test: adjust.

commit 2a50320c24a8290f6262a69dbc6465989f377df3
Author: Noah Lavine <address@hidden>
Date:   Wed Feb 20 11:16:32 2013 -0500

    Compile let to CPS
    
    * module/language/tree-il/compile-cps.scm: support 'let'.
    * test-suite/tests/cps.test: test 'let'.

commit 0c8f13d559e8ad379d0b6fc1ff26fe43f243e013
Author: Noah Lavine <address@hidden>
Date:   Wed Feb 20 11:14:06 2013 -0500

    Bugfix in CPS Printer
    
    * module/language/cps.scm: CPS printer will now work.

commit 71a43ae7ea77acbad5b75d82098349c8d24e8e83
Author: Noah Lavine <address@hidden>
Date:   Tue Feb 19 23:43:47 2013 -0500

    Add CPS Printer
    
    * module/language/cps.scm: add CPS printer, using unparse-cps.

commit 22823ad400b6f6e6469c152f2908bd96ad52e63c
Author: Noah Lavine <address@hidden>
Date:   Tue Feb 19 23:30:31 2013 -0500

    Sequences in CPS
    
    * module/language/cps.scm: let continuations take rest arguments.
    * module/language/tree-il/compile-cps.scm: compile sequences.
    * module/language/cps/compile-rtl.scm: handle rest arguments.
    * test-suite/tests/cps.test: test sequences.
    
    Note: sequences and rest arguments are grouped together because rest
    arguments are needed for sequences, and sequences are used to test rest
    arguments.

commit 518f03a79d0383a24d9af9399ffc662a8ebb96bc
Author: Noah Lavine <address@hidden>
Date:   Tue Feb 19 21:51:10 2013 -0500

    Lexical Sets in CPS
    
    * module/language/tree-il/compile-cps.scm: compile lexical-sets to CPS.
    * module/language/cps/compile-rtl.scm: fix bug in lexical set
      implementation.
    * test-suite/tests/cps.test: test lexical sets.

commit a240d1edf1b314bdda9bdaf2da0ee4a1c7bf8567
Author: Noah Lavine <address@hidden>
Date:   Tue Feb 19 11:47:47 2013 -0500

    CPS Compiler Function
    
    * module/language/cps/spec.scm: add module. Has 'cps-compile', like
      regular 'compile' but using CPS.
    * module/language/cps/compile-rtl.scm: remove duplicate functionality.
    * test-suite/tests/cps.test: use 'cps-compile'.

commit a451fc92d75ca6691e9682a71f77163a4379fc9f
Author: Noah Lavine <address@hidden>
Date:   Tue Feb 19 11:32:53 2013 -0500

    Adopt Naming Convention
    
    * module/language/cps.scm: add note on using "value" and "variable"
      consistently.
    * module/language/tree-il/compile-cps.scm: adjust.
    * module/language/cps/compile-rtl.scm: adjust.

commit cb1859ed3c97146a0e9797532dc950a5c79ab068
Author: Noah Lavine <address@hidden>
Date:   Mon Feb 18 14:10:58 2013 -0500

    Make Lambda Arguments Mutable
    
    * module/language/cps.scm: let variable objects come with an
      initialization value.
    * module/language/tree-il/compile-cps.scm: put all lambda arguments in
      variable boxes, so they are mutable.

commit b57621e62ae2b5c5224b6334785855f1bb349c0c
Author: Noah Lavine <address@hidden>
Date:   Mon Feb 18 14:09:33 2013 -0500

    Allocate Call Frames Explicitly
    
    * module/language/cps/compile-rtl.scm: have the allocator explicitly say
      where to put the frame for a procedure call, instead of inferring it
      from the argument destinations.

commit 1b50c36edef2d8fd0e04fa0bed890546203ddc54
Author: Noah Lavine <address@hidden>
Date:   Sat Feb 16 12:08:45 2013 -0500

    Support N-ary Primitive Outputs
    
    * module/language/cps/primitives.scm: add new data table for output
      arity.
    * module/language/cps/compile-rtl.scm: adjust.

commit 14922acd705d62932e095675a2407d7fcd5db1c4
Author: Noah Lavine <address@hidden>
Date:   Fri Feb 15 23:10:58 2013 -0500

    Clean Up the Register Allocator
    
    * module/language/cps/compile-rtl.scm: code clean-ups in the register
      allocator.

commit 169ed53f82bb9d6c5b518a9d6b2ed538f500b240
Author: Noah Lavine <address@hidden>
Date:   Fri Feb 15 19:16:58 2013 -0500

    Rename 'name-value' to 'name-defn'
    
    * module/language/cps/compile-rtl.scm: change 'name-value' to
      'name-defn' for clarity.

commit e2eea905032dbd57356154fd6942394fac770c1b
Author: Noah Lavine <address@hidden>
Date:   Fri Feb 15 19:07:39 2013 -0500

    Test + Function
    
    * test-suite/tests/cps.test: since we can now access top-level
      variables, test that the + function works (instead of the CPS
      primitive +).

commit 4f4c8b9a3460a0da22b325fe3b9125e17903688d
Author: Noah Lavine <address@hidden>
Date:   Fri Feb 15 17:25:17 2013 -0500

    Separate CPS and CPS-Data
    
    * module/language/cps.scm: split 'cps' declaration into 'cps' and
      'cps-data', to make the use of the cps-data types more clear. also add
      a 'const' type for completeness.
    * module/language/tree-il/compile-cps.scm: adjust.
    * module/language/cps/compile-rtl.scm: adjust.
    * test-suite/tests/cps.test: adjust.

commit d4fa79fc07edb78eada294c739a5077581c9c832
Author: Noah Lavine <address@hidden>
Date:   Fri Feb 15 16:10:07 2013 -0500

    Toplevel Sets in CPS
    
    * module/language/tree-il/compile-cps.scm: compile toplevel sets to
      a new CPS primitive called 'set'.
    * module/language/cps/compile-rtl.scm: compile 'set' to toplevel set
      instructions.
    * test-suite/tests/cps.test: test toplevel sets.

commit 8250248a8aba3b799d096d6cccc07489f8401fcc
Author: Noah Lavine <address@hidden>
Date:   Thu Feb 7 23:27:27 2013 -0500

    Toplevel Refs in CPS
    
    * module/language/cps.scm: new CPS forms to represent mutable variables.
    * module/language/tree-il/compile-cps.scm: generate CPS for top-level
      references.
    * module/language/cps/compile-rtl.scm: generate RTL code for top-level
      references.
    * test-suite/tests/cps.test: test top-level references.

commit f06f9f9a670d062238da7a1096274d909322993d
Author: Noah Lavine <address@hidden>
Date:   Fri Jan 25 09:52:36 2013 -0500

    More CPS Primitives
    
    * module/language/cps/primitives.scm: add more primitives to our
      tables.

commit 7e653a14720c9d538285e47f3ee1c59f261469c6
Author: Noah Lavine <address@hidden>
Date:   Thu Jan 24 23:25:53 2013 -0500

    Begin Tree-IL->CPS Compiler
    
    * module/language/tree-il/compile-cps.scm: add (partial) Tree-IL->CPS
      compiler.
    * test-suite/tests/cps.test: test Tree-IL->CPS compiler by using it in
      CPS tests.

commit 3388b2909f97eeb2d51116f03c235fedb5ef048c
Author: Noah Lavine <address@hidden>
Date:   Thu Jan 24 23:23:03 2013 -0500

    Simplify CPS If
    
    * module/language/cps.scm: simplify CPS `if'.
    * module/language/cps/compile-rtl.scm: compile simpler `if'.
    * test-suite/tests/cps.test: test new, simpler form of `if'.

commit 9c7ac4455102cde2a5cab4ec47a7034c36e78048
Author: Noah Lavine <address@hidden>
Date:   Sat Nov 17 09:35:15 2012 -0500

    Bugfix in compiling CPS 'if'
    
    * module/language/cps/compile-rtl.scm: generate a br instruction to skip
      the alternate branch in an <if> if the test is true.

commit a4659be4915160527994bbce6c51f2175f22902a
Author: Noah Lavine <address@hidden>
Date:   Fri Nov 16 23:00:01 2012 -0500

    Compile CPS primitive '+'
    
    * module/language/cps/primitives.scm: new files holds information on
      primitives. currently only '+'.
    * module/language/cps/compile-rtl.scm: compile simple primitives.

commit e518855430bea39fa784ea0128f976b651dea0a4
Author: Noah Lavine <address@hidden>
Date:   Fri Nov 16 22:03:21 2012 -0500

    Compile CPS 'if'
    
    * module/language/cps/compile-rtl.scm: compile the <if> form.
    * test-suite/tests/cps.test: test that the <if> form compiles correctly.

commit ebf6f50e82e86da2710bec076e4dfc3f2a7b77a0
Author: Noah Lavine <address@hidden>
Date:   Fri Nov 16 21:40:02 2012 -0500

    Primitive and if in CPS
    
    * module/language/cps.scm: add <primitive> and <if> CPS types.

commit 2724a1bedae60795c409d0c992db4b76902b227c
Author: Noah Lavine <address@hidden>
Date:   Fri Nov 16 20:57:49 2012 -0500

    Parser and unparser for CPS
    
    * module/language/cps.scm: add parse-cps and unparse-cps.
    * test-suite/tests/cps.test: use parse-cps.

commit 9db0d53c8076d2c64fe7ea0c37f1ea7ca7485fe2
Author: Noah Lavine <address@hidden>
Date:   Fri Nov 16 20:31:01 2012 -0500

    Factor CPS Code
    
    * module/language/cps.scm: remove RTL compilation functions and tests.
    * module/language/cps/compile-rtl.scm: new location for CPS->RTL
      compiler.
    * test-suite/tests/cps.test: new location for CPS->RTL compiler tests.

commit 42cce87a63b1530d1613edb4807777d66e2564e3
Author: Noah Lavine <address@hidden>
Date:   Sun Nov 4 23:19:19 2012 -0500

    Record-based CPS Representation
    
    * module/language/cps.scm: use records to represent all CPS
      constructs, instead of most of them. Make dispatches more
      uniform by using record-case and match on the new records.

commit cc9f2d2ea16b078f16b19a5db48beb19e2a64e03
Author: Noah Lavine <address@hidden>
Date:   Fri Nov 2 21:30:53 2012 -0400

    Add Identity Test
    
    * module/language/cps.scm: make sure we can compile the identity
      function.

commit b45297eb7184abcf4abc2bbd285ca694448f5d11
Author: Noah Lavine <address@hidden>
Date:   Fri Nov 2 21:08:13 2012 -0400

    Make Allocation Automatic
    
    * module/language/cps.scm: cps->rtl automatically calls
      allocate-registers-and-labels!

commit d46ac9f5e805f3bb2e924d50293fbd891103af05
Author: Noah Lavine <address@hidden>
Date:   Thu Nov 1 11:37:42 2012 -0400

    Support Non-tail Calls
    
    * module/language/cps.scm: add new test case 'compose'. Add support
      for non-tail calls so it works correctly.

commit 0d0fef29963519cf3bc77a65525dc227ac9a8423
Author: Noah Lavine <address@hidden>
Date:   Sat Oct 27 11:51:38 2012 -0400

    Better register allocation
    
    * module/language/cps.scm: finish register allocator. It should now
      handle all cases.

commit 27a81805c441a77f0218ed5e3445995e6c740e5b
Author: Noah Lavine <address@hidden>
Date:   Sat Oct 27 11:36:57 2012 -0400

    First work on CPS
    
    * module/language/cps.scm: add bare-bones CPS. Can only compile a
      few things.

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

Summary of changes:
 .gitignore                                         |    6 +
 GNUmakefile                                        |    2 +-
 Makefile.am                                        |   19 +-
 NEWS                                               |  409 +++++-
 README                                             |    4 +-
 THANKS                                             |   18 +-
 build-aux/announce-gen                             |    2 +-
 build-aux/config.rpath                             |    2 +-
 build-aux/gendocs.sh                               |  160 ++-
 build-aux/git-version-gen                          |   38 +-
 build-aux/gitlog-to-changelog                      |    2 +-
 build-aux/gnu-web-doc-update                       |   33 +-
 build-aux/gnupload                                 |   19 +-
 build-aux/snippet/arg-nonnull.h                    |    2 +-
 build-aux/snippet/c++defs.h                        |    2 +-
 build-aux/snippet/unused-parameter.h               |    2 +-
 build-aux/snippet/warn-on-use.h                    |    4 +-
 build-aux/useless-if-before-free                   |    2 +-
 build-aux/vc-list-files                            |    2 +-
 configure.ac                                       |   70 +-
 doc/gendocs_template                               |    2 +-
 doc/guile-api.alist                                |    1 -
 doc/r5rs/r5rs.texi                                 |    3 +-
 doc/ref/Makefile.am                                |    7 +
 doc/ref/api-binding.texi                           |    4 +-
 doc/ref/api-compound.texi                          |  169 +--
 doc/ref/api-control.texi                           |   64 +-
 doc/ref/api-data.texi                              |  206 ++-
 doc/ref/api-debug.texi                             |    6 +-
 doc/ref/api-evaluation.texi                        |  104 +-
 doc/ref/api-foreign.texi                           |    6 +-
 doc/ref/api-io.texi                                |  192 ++-
 doc/ref/api-macros.texi                            |   28 +-
 doc/ref/api-modules.texi                           |  155 +--
 doc/ref/api-options.texi                           |   15 +-
 doc/ref/api-procedures.texi                        |   18 +-
 doc/ref/api-scheduling.texi                        |   19 +-
 doc/ref/api-smobs.texi                             |    6 +-
 doc/ref/api-undocumented.texi                      |    6 +-
 doc/ref/api-utility.texi                           |    6 +-
 doc/ref/compiler.texi                              |   16 +-
 doc/ref/guile-invoke.texi                          |   60 +-
 doc/ref/guile.texi                                 |    2 +-
 doc/ref/intro.texi                                 |   21 +-
 doc/ref/misc-modules.texi                          |    3 +
 doc/ref/posix.texi                                 |   90 +-
 doc/ref/r6rs.texi                                  |   18 +-
 doc/ref/scheme-using.texi                          |   20 +-
 doc/ref/srfi-modules.texi                          |  757 +++++++++-
 doc/ref/sxml-match.texi                            |   10 +-
 doc/ref/sxml.texi                                  | 1075 ++++++++------
 doc/ref/texinfo.texi                               |   22 +-
 doc/ref/web.texi                                   |  102 +-
 doc/release.org                                    |   17 +-
 gnulib-local/build-aux/git-version-gen.diff        |   47 +-
 guile-readline/readline.c                          |   32 +-
 lib/Makefile.am                                    |  171 ++-
 lib/accept.c                                       |    2 +-
 lib/alignof.h                                      |    2 +-
 lib/alloca.c                                       |  478 ++++++
 lib/alloca.in.h                                    |    2 +-
 lib/arpa_inet.in.h                                 |    2 +-
 lib/asnprintf.c                                    |    2 +-
 lib/basename-lgpl.c                                |    2 +-
 lib/binary-io.h                                    |    2 +-
 lib/bind.c                                         |    2 +-
 lib/btowc.c                                        |    2 +-
 lib/byteswap.in.h                                  |    2 +-
 lib/c-ctype.c                                      |    2 +-
 lib/c-ctype.h                                      |    2 +-
 lib/c-strcase.h                                    |    2 +-
 lib/c-strcasecmp.c                                 |    2 +-
 lib/c-strcaseeq.h                                  |    2 +-
 lib/c-strncasecmp.c                                |    2 +-
 lib/canonicalize-lgpl.c                            |   78 +-
 lib/ceil.c                                         |    2 +-
 lib/close.c                                        |    2 +-
 lib/config.charset                                 |    2 +-
 lib/connect.c                                      |    2 +-
 lib/dirent.in.h                                    |    2 +-
 lib/dirfd.c                                        |    2 +-
 lib/dirname-lgpl.c                                 |    2 +-
 lib/dirname.h                                      |    2 +-
 lib/dosname.h                                      |    2 +-
 lib/dup2.c                                         |  160 ++
 lib/duplocale.c                                    |    2 +-
 lib/errno.in.h                                     |    2 +-
 lib/fcntl.in.h                                     |    2 +-
 lib/fd-hook.c                                      |    2 +-
 lib/fd-hook.h                                      |    2 +-
 lib/float+.h                                       |    2 +-
 lib/float.c                                        |    2 +-
 lib/float.in.h                                     |    2 +-
 lib/flock.c                                        |    2 +-
 lib/floor.c                                        |    2 +-
 lib/frexp.c                                        |    2 +-
 lib/fstat.c                                        |    6 +-
 lib/full-read.c                                    |    2 +-
 lib/full-read.h                                    |    2 +-
 lib/full-write.c                                   |    2 +-
 lib/full-write.h                                   |    2 +-
 lib/gai_strerror.c                                 |    2 +-
 lib/getaddrinfo.c                                  |    8 +-
 lib/getlogin.c                                     |   41 +
 lib/getpeername.c                                  |    2 +-
 lib/getsockname.c                                  |    2 +-
 lib/getsockopt.c                                   |    2 +-
 lib/gettext.h                                      |    2 +-
 lib/iconv.c                                        |    2 +-
 lib/iconv.in.h                                     |    2 +-
 lib/iconv_close.c                                  |    2 +-
 lib/iconv_open.c                                   |    2 +-
 lib/iconveh.h                                      |    2 +-
 lib/inet_ntop.c                                    |    2 +-
 lib/inet_pton.c                                    |    2 +-
 lib/isinf.c                                        |    2 +-
 lib/isnan.c                                        |    2 +-
 lib/isnand-nolibm.h                                |    2 +-
 lib/isnand.c                                       |    2 +-
 lib/isnanf.c                                       |    2 +-
 lib/isnanl.c                                       |    2 +-
 lib/itold.c                                        |    2 +-
 lib/langinfo.in.h                                  |    2 +-
 lib/listen.c                                       |    2 +-
 lib/localcharset.c                                 |    2 +-
 lib/localcharset.h                                 |    2 +-
 lib/locale.in.h                                    |   21 +-
 lib/localeconv.c                                   |    2 +-
 lib/log.c                                          |    2 +-
 lib/log1p.c                                        |    2 +-
 lib/lstat.c                                        |    4 +-
 lib/malloc.c                                       |    2 +-
 lib/malloca.c                                      |    2 +-
 lib/malloca.h                                      |    2 +-
 lib/math.c                                         |    3 +
 lib/math.in.h                                      |   15 +-
 lib/mbrtowc.c                                      |    2 +-
 lib/mbsinit.c                                      |    2 +-
 lib/mbtowc-impl.h                                  |    2 +-
 lib/mbtowc.c                                       |    2 +-
 lib/memchr.c                                       |    2 +-
 lib/msvc-inval.c                                   |    2 +-
 lib/msvc-inval.h                                   |    2 +-
 lib/msvc-nothrow.c                                 |    2 +-
 lib/msvc-nothrow.h                                 |    2 +-
 lib/netdb.in.h                                     |    2 +-
 lib/netinet_in.in.h                                |    2 +-
 lib/nl_langinfo.c                                  |    2 +-
 lib/nproc.c                                        |    2 +-
 lib/nproc.h                                        |    2 +-
 lib/open.c                                         |    4 +-
 lib/pathmax.h                                      |    2 +-
 lib/pipe.c                                         |   50 +
 lib/pipe2.c                                        |    2 +-
 lib/poll.c                                         |  611 +++++++
 lib/poll.in.h                                      |  103 ++
 lib/printf-args.c                                  |    2 +-
 lib/printf-args.h                                  |    2 +-
 lib/printf-parse.c                                 |    2 +-
 lib/printf-parse.h                                 |    2 +-
 lib/putenv.c                                       |   34 +-
 lib/raise.c                                        |    4 +-
 lib/read.c                                         |    4 +-
 lib/readlink.c                                     |    2 +-
 lib/recv.c                                         |    2 +-
 lib/recvfrom.c                                     |    2 +-
 lib/ref-add.sin                                    |    2 +-
 lib/ref-del.sin                                    |    2 +-
 lib/regcomp.c                                      |   64 +-
 lib/regex.c                                        |   21 +-
 lib/regex.h                                        |   23 +-
 lib/regex_internal.c                               |   31 +-
 lib/regex_internal.h                               |   70 +-
 lib/regexec.c                                      |   49 +-
 lib/rename.c                                       |    2 +-
 lib/rmdir.c                                        |    2 +-
 lib/round.c                                        |    2 +-
 lib/safe-read.c                                    |    2 +-
 lib/safe-read.h                                    |    2 +-
 lib/safe-write.c                                   |    2 +-
 lib/safe-write.h                                   |    2 +-
 lib/same-inode.h                                   |    2 +-
 lib/select.c                                       |  547 +++++++
 lib/send.c                                         |    2 +-
 lib/sendto.c                                       |    2 +-
 lib/setenv.c                                       |   10 +-
 lib/setsockopt.c                                   |    2 +-
 lib/shutdown.c                                     |    2 +-
 lib/signal.in.h                                    |    2 +-
 lib/size_max.h                                     |    2 +-
 lib/snprintf.c                                     |    2 +-
 lib/socket.c                                       |    2 +-
 lib/sockets.c                                      |    2 +-
 lib/sockets.h                                      |    2 +-
 lib/stat-time.h                                    |    2 +-
 lib/stat.c                                         |    4 +-
 lib/stdalign.in.h                                  |    2 +-
 lib/stdbool.in.h                                   |    2 +-
 lib/stddef.in.h                                    |    2 +-
 lib/stdint.in.h                                    |    4 +-
 lib/stdio.in.h                                     |   23 +-
 lib/stdlib.in.h                                    |   23 +-
 lib/streq.h                                        |    2 +-
 lib/strftime.c                                     |   16 +-
 lib/strftime.h                                     |    2 +-
 lib/striconveh.c                                   |    2 +-
 lib/striconveh.h                                   |    2 +-
 lib/string.in.h                                    |    2 +-
 lib/stripslash.c                                   |    2 +-
 lib/sys_file.in.h                                  |    2 +-
 lib/sys_select.in.h                                |  309 ++++
 lib/sys_socket.c                                   |    3 +
 lib/sys_socket.in.h                                |   11 +-
 lib/sys_stat.in.h                                  |    8 +-
 lib/sys_time.in.h                                  |  190 ++--
 lib/sys_times.in.h                                 |   80 +
 lib/sys_types.in.h                                 |    2 +-
 lib/sys_uio.in.h                                   |    2 +-
 lib/time.in.h                                      |    2 +-
 lib/time_r.c                                       |    2 +-
 lib/times.c                                        |   66 +
 lib/trunc.c                                        |    2 +-
 lib/unistd.c                                       |    3 +
 lib/unistd.in.h                                    |   35 +-
 lib/unistr.in.h                                    |    2 +-
 lib/unistr/u8-mbtouc-aux.c                         |    2 +-
 lib/unistr/u8-mbtouc-unsafe-aux.c                  |    2 +-
 lib/unistr/u8-mbtouc-unsafe.c                      |    2 +-
 lib/unistr/u8-mbtouc.c                             |    2 +-
 lib/unistr/u8-mbtoucr.c                            |    2 +-
 lib/unistr/u8-prev.c                               |    2 +-
 lib/unistr/u8-uctomb-aux.c                         |    2 +-
 lib/unistr/u8-uctomb.c                             |    2 +-
 lib/unitypes.in.h                                  |    2 +-
 lib/vasnprintf.c                                   |    4 +-
 lib/vasnprintf.h                                   |    2 +-
 lib/verify.h                                       |    2 +-
 lib/vsnprintf.c                                    |    2 +-
 lib/w32sock.h                                      |    2 +-
 lib/wchar.in.h                                     |    2 +-
 lib/wcrtomb.c                                      |    2 +-
 lib/wctype-h.c                                     |    4 +
 lib/wctype.in.h                                    |   40 +-
 lib/write.c                                        |    4 +-
 lib/xsize.h                                        |    2 +-
 libguile/Makefile.am                               |   31 +-
 libguile/__scm.h                                   |    2 +-
 libguile/array-handle.c                            |   44 +-
 libguile/array-handle.h                            |   36 +-
 libguile/array-map.c                               |  196 ++-
 libguile/array-map.h                               |   29 +-
 libguile/bdw-gc.h                                  |    7 +-
 libguile/c-tokenize.lex                            |    3 +-
 libguile/debug.c                                   |   49 +-
 libguile/debug.h                                   |    4 +-
 libguile/deprecated.c                              |   84 +-
 libguile/error.c                                   |   17 +-
 libguile/filesys.c                                 |  279 ++--
 libguile/filesys.h                                 |    4 +-
 libguile/fluids.c                                  |   11 +-
 libguile/foreign.c                                 |  139 ++-
 libguile/fports.c                                  |  349 ++---
 libguile/fports.h                                  |    3 +
 libguile/gc.c                                      |   16 +-
 libguile/gc.h                                      |    3 +-
 libguile/gen-scmconfig.c                           |   21 +-
 libguile/generalized-arrays.c                      |  143 ++-
 libguile/generalized-arrays.h                      |   11 +-
 libguile/generalized-vectors.c                     |   68 +-
 libguile/generalized-vectors.h                     |    8 +-
 libguile/guardians.c                               |    8 +-
 libguile/guile.c                                   |   36 +-
 libguile/hashtab.c                                 |   28 +
 libguile/hashtab.h                                 |    1 +
 libguile/i18n.c                                    |    4 +-
 libguile/init.c                                    |    4 +-
 libguile/inline.c                                  |    3 +-
 libguile/inline.h                                  |   25 +-
 libguile/instructions.c                            |    6 +-
 libguile/iselect.h                                 |   34 +-
 libguile/keywords.c                                |   67 +
 libguile/keywords.h                                |   12 +
 libguile/list.c                                    |    2 -
 libguile/load.c                                    |  127 ++-
 libguile/load.h                                    |    3 +-
 libguile/memoize.c                                 |   28 +-
 libguile/mkstemp.c                                 |    4 +-
 libguile/net_db.c                                  |   56 +-
 libguile/numbers.c                                 | 1675 +++++++++++++-------
 libguile/numbers.h                                 |   18 +-
 libguile/objcodes.c                                |  548 ++++---
 libguile/poll.c                                    |   15 +-
 libguile/ports-internal.h                          |   66 +
 libguile/ports.c                                   |  558 +++++--
 libguile/ports.h                                   |   80 +-
 libguile/posix.c                                   |  113 +-
 libguile/print.c                                   |   31 +-
 libguile/procprop.c                                |  105 ++-
 libguile/procprop.h                                |    6 +-
 libguile/procs.c                                   |   15 -
 libguile/procs.h                                   |    5 +-
 libguile/programs.c                                |  111 ++-
 libguile/programs.h                                |   10 +-
 libguile/r6rs-ports.c                              |  143 +-
 libguile/random.c                                  |   14 +-
 libguile/read.c                                    |   42 +-
 libguile/scmsigs.c                                 |   34 +-
 libguile/smob.c                                    |   49 +-
 libguile/socket.c                                  |   51 +-
 libguile/srfi-13.c                                 |  124 +-
 libguile/srfi-14.i.c                               |    8 +-
 libguile/stime.c                                   |   31 +-
 libguile/strings.c                                 |   42 +-
 libguile/strports.c                                |    9 +-
 libguile/struct.c                                  |   10 +-
 libguile/struct.h                                  |    6 +-
 libguile/texi-fragments-to-docstrings              |   55 +
 libguile/threads.c                                 |   34 +-
 libguile/threads.h                                 |    7 +-
 libguile/uniform.c                                 |    4 +-
 libguile/vm-engine.c                               |  388 +++---
 libguile/vm.c                                      |   18 +-
 libguile/vports.c                                  |    8 +-
 libguile/win32-socket.c                            |  632 --------
 libguile/win32-socket.h                            |   42 -
 m4/00gnulib.m4                                     |    2 +-
 m4/absolute-header.m4                              |    2 +-
 m4/alloca.m4                                       |    2 +-
 m4/arpa_inet_h.m4                                  |    2 +-
 m4/autobuild.m4                                    |    2 +-
 m4/btowc.m4                                        |    2 +-
 m4/byteswap.m4                                     |    2 +-
 m4/canonicalize.m4                                 |    2 +-
 m4/ceil.m4                                         |    2 +-
 m4/check-math-lib.m4                               |    2 +-
 m4/clock_time.m4                                   |    2 +-
 m4/close.m4                                        |    2 +-
 m4/codeset.m4                                      |    2 +-
 m4/configmake.m4                                   |    2 +-
 m4/dirent_h.m4                                     |    2 +-
 m4/dirfd.m4                                        |    2 +-
 m4/dirname.m4                                      |    2 +-
 m4/double-slash-root.m4                            |    2 +-
 m4/dup2.m4                                         |   84 +
 m4/duplocale.m4                                    |    2 +-
 m4/eealloc.m4                                      |    2 +-
 m4/environ.m4                                      |    2 +-
 m4/errno_h.m4                                      |    2 +-
 m4/exponentd.m4                                    |    2 +-
 m4/exponentf.m4                                    |    2 +-
 m4/exponentl.m4                                    |    2 +-
 m4/extensions.m4                                   |   49 +-
 m4/extern-inline.m4                                |   23 +-
 m4/fcntl-o.m4                                      |    2 +-
 m4/fcntl_h.m4                                      |    2 +-
 m4/float_h.m4                                      |    2 +-
 m4/flock.m4                                        |    2 +-
 m4/floor.m4                                        |    2 +-
 m4/fpieee.m4                                       |    2 +-
 m4/frexp.m4                                        |    2 +-
 m4/fstat.m4                                        |    9 +-
 m4/func.m4                                         |    2 +-
 m4/getaddrinfo.m4                                  |    5 +-
 m4/getlogin.m4                                     |   14 +
 m4/glibc21.m4                                      |    2 +-
 m4/gnulib-cache.m4                                 |   12 +-
 m4/gnulib-common.m4                                |    8 +-
 m4/gnulib-comp.m4                                  |   77 +-
 m4/gnulib-tool.m4                                  |    2 +-
 m4/hostent.m4                                      |    2 +-
 m4/iconv.m4                                        |    2 +-
 m4/iconv_h.m4                                      |    2 +-
 m4/iconv_open-utf.m4                               |    2 +-
 m4/iconv_open.m4                                   |    2 +-
 m4/include_next.m4                                 |    2 +-
 m4/inet_ntop.m4                                    |    2 +-
 m4/inet_pton.m4                                    |    2 +-
 m4/inline.m4                                       |    2 +-
 m4/intmax_t.m4                                     |    2 +-
 m4/inttypes_h.m4                                   |    2 +-
 m4/isinf.m4                                        |    2 +-
 m4/isnan.m4                                        |    2 +-
 m4/isnand.m4                                       |    2 +-
 m4/isnanf.m4                                       |    2 +-
 m4/isnanl.m4                                       |    2 +-
 m4/langinfo_h.m4                                   |    2 +-
 m4/largefile.m4                                    |   25 +-
 m4/ld-version-script.m4                            |    2 +-
 m4/ldexp.m4                                        |    2 +-
 m4/lib-ld.m4                                       |    2 +-
 m4/lib-link.m4                                     |    2 +-
 m4/lib-prefix.m4                                   |    2 +-
 m4/libunistring-base.m4                            |    2 +-
 m4/libunistring.m4                                 |    2 +-
 m4/localcharset.m4                                 |    2 +-
 m4/locale-fr.m4                                    |    2 +-
 m4/locale-ja.m4                                    |    2 +-
 m4/locale-zh.m4                                    |    2 +-
 m4/locale_h.m4                                     |    2 +-
 m4/localeconv.m4                                   |    2 +-
 m4/log.m4                                          |    2 +-
 m4/log1p.m4                                        |    2 +-
 m4/longlong.m4                                     |    2 +-
 m4/lstat.m4                                        |   10 +-
 m4/malloc.m4                                       |    2 +-
 m4/malloca.m4                                      |    2 +-
 m4/math_h.m4                                       |    5 +-
 m4/mathfunc.m4                                     |    2 +-
 m4/mbrtowc.m4                                      |    2 +-
 m4/mbsinit.m4                                      |    2 +-
 m4/mbstate_t.m4                                    |    2 +-
 m4/mbtowc.m4                                       |    2 +-
 m4/memchr.m4                                       |    2 +-
 m4/mmap-anon.m4                                    |    2 +-
 m4/mode_t.m4                                       |    2 +-
 m4/msvc-inval.m4                                   |    2 +-
 m4/msvc-nothrow.m4                                 |    2 +-
 m4/multiarch.m4                                    |    2 +-
 m4/netdb_h.m4                                      |    2 +-
 m4/netinet_in_h.m4                                 |    2 +-
 m4/nl_langinfo.m4                                  |    2 +-
 m4/nocrash.m4                                      |    2 +-
 m4/nproc.m4                                        |    2 +-
 m4/off_t.m4                                        |    2 +-
 m4/open.m4                                         |    5 +-
 m4/pathmax.m4                                      |    2 +-
 m4/pipe.m4                                         |   15 +
 m4/pipe2.m4                                        |    2 +-
 m4/poll.m4                                         |  103 ++
 m4/poll_h.m4                                       |   47 +
 m4/printf.m4                                       |    2 +-
 m4/putenv.m4                                       |    8 +-
 m4/raise.m4                                        |    8 +-
 m4/read.m4                                         |    9 +-
 m4/readlink.m4                                     |    2 +-
 m4/regex.m4                                        |   85 +-
 m4/rename.m4                                       |    2 +-
 m4/rmdir.m4                                        |    2 +-
 m4/round.m4                                        |    2 +-
 m4/safe-read.m4                                    |    2 +-
 m4/safe-write.m4                                   |    2 +-
 m4/select.m4                                       |  113 ++
 m4/servent.m4                                      |    2 +-
 m4/setenv.m4                                       |    2 +-
 m4/signal_h.m4                                     |    2 +-
 m4/size_max.m4                                     |    2 +-
 m4/snprintf.m4                                     |    2 +-
 m4/socketlib.m4                                    |    2 +-
 m4/sockets.m4                                      |    2 +-
 m4/socklen.m4                                      |    2 +-
 m4/sockpfaf.m4                                     |    2 +-
 m4/ssize_t.m4                                      |    2 +-
 m4/stat-time.m4                                    |    2 +-
 m4/stat.m4                                         |   10 +-
 m4/stdalign.m4                                     |    2 +-
 m4/stdbool.m4                                      |    2 +-
 m4/stddef_h.m4                                     |    2 +-
 m4/stdint.m4                                       |    2 +-
 m4/stdint_h.m4                                     |    2 +-
 m4/stdio_h.m4                                      |    5 +-
 m4/stdlib_h.m4                                     |    8 +-
 m4/strftime.m4                                     |    2 +-
 m4/string_h.m4                                     |    2 +-
 m4/sys_file_h.m4                                   |    2 +-
 m4/sys_select_h.m4                                 |   95 ++
 m4/sys_socket_h.m4                                 |    5 +-
 m4/sys_stat_h.m4                                   |    7 +-
 m4/sys_time_h.m4                                   |    2 +-
 m4/sys_times_h.m4                                  |   51 +
 m4/sys_types_h.m4                                  |    2 +-
 m4/sys_uio_h.m4                                    |    2 +-
 m4/time_h.m4                                       |    2 +-
 m4/time_r.m4                                       |    2 +-
 m4/times.m4                                        |   14 +
 m4/tm_gmtoff.m4                                    |    2 +-
 m4/trunc.m4                                        |    2 +-
 m4/unistd_h.m4                                     |    5 +-
 m4/vasnprintf.m4                                   |    5 +-
 m4/visibility.m4                                   |    2 +-
 m4/vsnprintf.m4                                    |    2 +-
 m4/warn-on-use.m4                                  |    2 +-
 m4/warnings.m4                                     |    2 +-
 m4/wchar_h.m4                                      |    2 +-
 m4/wchar_t.m4                                      |    2 +-
 m4/wcrtomb.m4                                      |    2 +-
 m4/wctype_h.m4                                     |    6 +-
 m4/wint_t.m4                                       |    2 +-
 m4/write.m4                                        |    9 +-
 m4/xsize.m4                                        |    2 +-
 maint.mk                                           |   17 +-
 meta/Makefile.am                                   |   14 +-
 meta/guild.in                                      |   10 +-
 meta/guile.in                                      |    4 +-
 meta/guile.m4                                      |  171 ++-
 module/Makefile.am                                 |   20 +-
 module/ice-9/binary-ports.scm                      |    3 +-
 module/ice-9/boot-9.scm                            |  424 ++++--
 module/ice-9/command-line.scm                      |   18 +-
 module/ice-9/control.scm                           |   32 +-
 module/ice-9/futures.scm                           |   34 +-
 module/ice-9/mapping.scm                           |   82 +-
 module/ice-9/psyntax-pp.scm                        |  225 ++--
 module/ice-9/psyntax.scm                           |  132 +-
 module/language/assembly/spec.scm                  |    3 +-
 module/language/bytecode/spec.scm                  |    3 +-
 module/language/cps/compile-rtl.scm                |    4 +-
 module/language/ecmascript/base.scm                |    5 +-
 module/language/glil/compile-assembly.scm          |   53 +-
 module/language/glil/decompile-assembly.scm        |  191 ---
 module/language/glil/spec.scm                      |    6 +-
 module/language/objcode/elf.scm                    |   40 +-
 module/language/objcode/spec.scm                   |    3 +-
 module/language/scheme/decompile-tree-il.scm       |   35 +-
 module/language/tree-il.scm                        |   22 +-
 module/language/tree-il/analyze.scm                |   13 +-
 module/language/tree-il/canonicalize.scm           |   17 +-
 module/language/tree-il/compile-glil.scm           |   17 +-
 module/language/tree-il/cse.scm                    |    8 +-
 module/language/tree-il/debug.scm                  |    7 +-
 module/language/tree-il/effects.scm                |    9 +-
 module/language/tree-il/peval.scm                  |  246 ++-
 module/language/tree-il/spec.scm                   |    3 +-
 module/language/value/spec.scm                     |    3 +-
 module/oop/goops.scm                               |   15 +-
 module/oop/goops/active-slot.scm                   |   19 +-
 module/oop/goops/composite-slot.scm                |   17 +-
 module/oop/goops/describe.scm                      |   17 +-
 module/oop/goops/save.scm                          |   41 +-
 module/srfi/srfi-27.scm                            |    2 +
 module/srfi/srfi-31.scm                            |    2 +
 module/srfi/srfi-37.scm                            |    5 +-
 module/srfi/srfi-38.scm                            |    1 +
 module/srfi/srfi-39.scm                            |    2 +
 module/srfi/srfi-4.scm                             |    1 +
 module/srfi/srfi-4/gnu.scm                         |    8 +-
 module/srfi/srfi-41.scm                            |  505 ++++++
 module/srfi/srfi-42.scm                            |    2 +
 module/srfi/srfi-45.scm                            |   30 +-
 module/srfi/srfi-67.scm                            |    2 +
 module/srfi/srfi-69.scm                            |    2 +-
 module/sxml/match.scm                              |   19 +-
 module/sxml/simple.scm                             |  188 +++-
 module/sxml/ssax.scm                               |   21 +-
 module/sxml/upstream/SSAX.scm                      |   31 +-
 module/system/base/compile.scm                     |    7 +-
 module/system/base/language.scm                    |    4 +-
 module/system/base/target.scm                      |   38 +-
 module/system/foreign.scm                          |    4 +-
 module/system/repl/command.scm                     |   27 +-
 module/system/repl/common.scm                      |    5 +-
 module/system/repl/repl.scm                        |    7 +-
 module/system/vm/assembler.scm                     | 1309 +++++++++++++++
 module/system/vm/debug.scm                         |  386 +++++
 module/system/vm/disassembler.scm                  |  341 ++++
 module/system/vm/dwarf.scm                         |   48 +-
 module/system/vm/elf.scm                           |  658 +++------
 module/system/vm/linker.scm                        |  537 +++++++
 module/system/vm/objcode.scm                       |    5 +-
 module/system/vm/program.scm                       |   74 +-
 module/system/vm/rtl.scm                           |  979 ------------
 module/texinfo.scm                                 |    8 +-
 module/texinfo/docbook.scm                         |    2 +-
 module/texinfo/plain-text.scm                      |   38 +-
 module/texinfo/serialize.scm                       |    5 +-
 module/texinfo/string-utils.scm                    |   15 +-
 module/web/client.scm                              |    6 +-
 module/web/http.scm                                |   93 +-
 module/web/response.scm                            |   33 +-
 module/web/uri.scm                                 |   28 +-
 test-suite/Makefile.am                             |    1 +
 test-suite/standalone/Makefile.am                  |   22 +-
 test-suite/standalone/test-ffi                     |   15 +
 test-suite/standalone/test-ffi-lib.c               |   17 +
 test-suite/standalone/test-language                |   25 +
 test-suite/standalone/test-language.el             |   11 +
 test-suite/standalone/test-language.js             |   12 +
 .../standalone/test-pthread-create-secondary.c     |   19 +-
 test-suite/standalone/test-round.c                 |   11 +-
 .../standalone/test-scm-c-bind-keyword-arguments.c |  201 +++
 test-suite/standalone/test-smob-mark.c             |  133 ++
 test-suite/test-suite/lib.scm                      |    9 +-
 test-suite/tests/00-socket.test                    |   17 +-
 test-suite/tests/alist.test                        |    4 +-
 test-suite/tests/arrays.test                       |   76 +-
 test-suite/tests/asm-to-bytecode.test              |   15 +-
 test-suite/tests/bitvectors.test                   |    3 +-
 test-suite/tests/bytevectors.test                  |   36 +-
 test-suite/tests/coding.test                       |  116 +-
 test-suite/tests/control.test                      |   30 +-
 test-suite/tests/ecmascript.test                   |    1 +
 test-suite/tests/elisp.test                        |    8 +-
 test-suite/tests/encoding-iso88591.test            |   10 +-
 test-suite/tests/encoding-iso88597.test            |   10 +-
 test-suite/tests/encoding-utf8.test                |   10 +-
 test-suite/tests/filesys.test                      |  100 ++-
 test-suite/tests/fluids.test                       |   32 +-
 test-suite/tests/foreign.test                      |   21 +-
 test-suite/tests/future.test                       |   18 +-
 test-suite/tests/gc.test                           |    4 +-
 test-suite/tests/hash.test                         |   28 +-
 test-suite/tests/i18n.test                         |   20 +-
 test-suite/tests/modules.test                      |    2 +-
 test-suite/tests/numbers.test                      |  578 ++++++--
 test-suite/tests/optargs.test                      |   29 +
 test-suite/tests/peval.test                        |  150 ++-
 test-suite/tests/popen.test                        |  354 ++--
 test-suite/tests/ports.test                        |  719 ++++++++-
 test-suite/tests/r6rs-ports.test                   |   24 -
 test-suite/tests/ramap.test                        |   58 +-
 test-suite/tests/rtl.test                          |  214 ++-
 test-suite/tests/srfi-35.test                      |   16 +-
 test-suite/tests/srfi-37.test                      |   24 +-
 test-suite/tests/srfi-4.test                       |   38 +-
 test-suite/tests/srfi-41.test                      |  680 ++++++++
 test-suite/tests/srfi-45.test                      |   10 +-
 test-suite/tests/sxml.simple.test                  |   85 +-
 test-suite/tests/syncase.test                      |   37 +-
 test-suite/tests/texinfo.serialize.test            |    4 +-
 test-suite/tests/texinfo.string-utils.test         |    9 +-
 test-suite/tests/texinfo.test                      |   66 +-
 test-suite/tests/threads.test                      |    9 +-
 test-suite/tests/tree-il.test                      |   47 +-
 test-suite/tests/vlist.test                        |    8 +-
 test-suite/tests/web-http.test                     |  114 ++
 624 files changed, 19703 insertions(+), 8210 deletions(-)
 create mode 100644 lib/alloca.c
 create mode 100644 lib/dup2.c
 create mode 100644 lib/getlogin.c
 create mode 100644 lib/math.c
 create mode 100644 lib/pipe.c
 create mode 100644 lib/poll.c
 create mode 100644 lib/poll.in.h
 create mode 100644 lib/select.c
 create mode 100644 lib/sys_select.in.h
 create mode 100644 lib/sys_socket.c
 create mode 100644 lib/sys_times.in.h
 create mode 100644 lib/times.c
 create mode 100644 lib/unistd.c
 create mode 100644 lib/wctype-h.c
 create mode 100644 libguile/ports-internal.h
 create mode 100644 libguile/texi-fragments-to-docstrings
 delete mode 100644 libguile/win32-socket.c
 delete mode 100644 libguile/win32-socket.h
 create mode 100644 m4/dup2.m4
 create mode 100644 m4/getlogin.m4
 create mode 100644 m4/pipe.m4
 create mode 100644 m4/poll.m4
 create mode 100644 m4/poll_h.m4
 create mode 100644 m4/select.m4
 create mode 100644 m4/sys_select_h.m4
 create mode 100644 m4/sys_times_h.m4
 create mode 100644 m4/times.m4
 delete mode 100644 module/language/glil/decompile-assembly.scm
 create mode 100644 module/srfi/srfi-41.scm
 create mode 100644 module/system/vm/assembler.scm
 create mode 100644 module/system/vm/debug.scm
 create mode 100644 module/system/vm/disassembler.scm
 create mode 100644 module/system/vm/linker.scm
 delete mode 100644 module/system/vm/rtl.scm
 create mode 100755 test-suite/standalone/test-language
 create mode 100644 test-suite/standalone/test-language.el
 create mode 100644 test-suite/standalone/test-language.js
 create mode 100644 test-suite/standalone/test-scm-c-bind-keyword-arguments.c
 create mode 100644 test-suite/standalone/test-smob-mark.c
 create mode 100644 test-suite/tests/srfi-41.test

diff --git a/.gitignore b/.gitignore
index fca51df..b136c7a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -150,4 +150,10 @@ INSTALL
 /lib/dirent.h
 /lib/langinfo.h
 /lib/wctype.h
+/build-aux/ar-lib
+/build-aux/test-driver
+*.trs
+/test-suite/standalone/test-smob-mark
+/test-suite/standalone/test-scm-values
+/test-suite/standalone/test-scm-to-latin1-string
 /libguile/vm-operations.h
diff --git a/GNUmakefile b/GNUmakefile
index 58f2ead..8759034 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -5,7 +5,7 @@
 # It is necessary if you want to build targets usually of interest
 # only to the maintainer.
 
-# Copyright (C) 2001, 2003, 2006-2012 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2003, 2006-2013 Free Software Foundation, Inc.
 
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/Makefile.am b/Makefile.am
index 3aa5ddd..8cdcc7e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
 ## Process this file with automake to produce Makefile.in.
 ##
 ##     Copyright (C) 1998, 1999, 2000, 2001, 2002, 2006, 2007,
-##        2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+##        2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
 ##
 ##   This file is part of GUILE.
 ##
@@ -42,6 +42,19 @@ SUBDIRS =                                    \
 libguileincludedir = $(pkgincludedir)/$(GUILE_EFFECTIVE_VERSION)
 libguileinclude_HEADERS = libguile.h
 
+schemelibdir = $(pkgdatadir)/$(GUILE_EFFECTIVE_VERSION)
+schemelib_DATA = libguile/guile-procedures.txt
+
+# Build it from here so that all the modules are compiled by the time we
+# build it.
+libguile/guile-procedures.txt: libguile/guile-procedures.texi
+       $(AM_V_GEN)                                             \
+       $(top_builddir)/meta/guile --no-auto-compile            \
+         "$(srcdir)/libguile/texi-fragments-to-docstrings"     \
+         "$(builddir)/libguile/guile-procedures.texi"          \
+         > address@hidden
+       @mv address@hidden $@
+
 EXTRA_DIST = LICENSE HACKING GUILE-VERSION                     \
             m4/ChangeLog-2008                                  \
             m4/gnulib-cache.m4                                 \
@@ -50,13 +63,15 @@ EXTRA_DIST = LICENSE HACKING GUILE-VERSION                  
\
             gnulib-local/lib/localcharset.h.diff               \
             gnulib-local/lib/localcharset.c.diff               \
             gnulib-local/m4/clock_time.m4.diff                 \
-            gnulib-local/build-aux/git-version-gen.diff
+            gnulib-local/build-aux/git-version-gen.diff        \
+            libguile/texi-fragments-to-docstrings
 
 TESTS = check-guile
 TESTS_ENVIRONMENT = @LOCALCHARSET_TESTS_ENVIRONMENT@
 
 ACLOCAL_AMFLAGS = -I m4
 
+CLEANFILES = libguile/guile-procedures.txt
 DISTCLEANFILES = check-guile.log
 
 DISTCHECK_CONFIGURE_FLAGS = --enable-error-on-warning
diff --git a/NEWS b/NEWS
index ebf5d61..5913301 100644
--- a/NEWS
+++ b/NEWS
@@ -1,10 +1,417 @@
 Guile NEWS --- history of user-visible changes.
-Copyright (C) 1996-2012 Free Software Foundation, Inc.
+Copyright (C) 1996-2013 Free Software Foundation, Inc.
 See the end for copying conditions.
 
 Please send Guile bug reports to address@hidden
 
 
+Changes in 2.0.9 (since 2.0.7):
+
+Note: 2.0.8 was a brown paper bag release that was never announced, but
+some mirrors may have picked it up.  Please do not use it.
+
+* Notable changes
+
+** New keyword arguments for procedures that open files
+
+The following procedures that open files now support keyword arguments
+to request binary I/O or to specify the character encoding for text
+files: `open-file', `open-input-file', `open-output-file',
+`call-with-input-file', `call-with-output-file', `with-input-from-file',
+`with-output-to-file', and `with-error-to-file'.
+
+It is also now possible to specify whether Guile should scan files for
+Emacs-style coding declarations.  This scan was done by default in
+versions 2.0.0 through 2.0.7, but now must be explicitly requested.
+
+See "File Ports" in the manual for details.
+
+** Rewritten guile.m4
+
+The `guile.m4' autoconf macros have been rewritten to use `guild' and
+`pkg-config' instead of the deprecated `guile-config' (which itself
+calls pkg-config).
+
+There is also a new macro, `GUILE_PKG', which allows packages to select
+the version of Guile that they want to compile against.  See "Autoconf
+Macros" in the manual, for more information.
+
+** Better Windows support
+
+Guile now correctly identifies absolute paths on Windows (MinGW), and
+creates files on that platform according to its path conventions.  See
+"File System" in the manual, for all details.
+
+In addition, the new Gnulib imports provide `select' and `poll' on
+Windows builds.
+
+As an incompatible change, systems that are missing <sys/select.h> were
+previously provided a public `scm_std_select' C function that defined a
+version of `select', but unhappily it also provided its own incompatible
+definitions for FD_SET, FD_ZERO, and other system interfaces.  Guile
+should not be setting these macros in public API, so this interface was
+removed on those plaforms (basically only MinGW).
+
+** Numerics improvements
+
+`number->string' now reliably outputs enough digits to produce the same
+number when read back in.  Previously, it mishandled subnormal numbers
+(printing them as "#.#"), and failed to distinguish between some
+distinct inexact numbers, e.g. 1.0 and (+ 1.0 (expt 2.0 -52)).  These
+problems had far-reaching implications, since the compiler uses
+`number->string' to serialize numeric constants into .go files.
+
+`sqrt' now produces exact rational results when possible, and handles
+very large or very small numbers more robustly.
+
+A number (ahem) of operations involving exact rationals have been
+optimized, most notably `integer-expt' and `expt'.
+
+`exact->inexact' now performs correct IEEE rounding.
+
+** New optimizations
+
+There were a number of improvements to the partial evaluator, allowing
+complete reduction of forms such as:
+
+  ((let ((_ 10)) (lambda () _)))
+
+  ((lambda _ _))
+
+  (apply (lambda _ _) 1 2 3 '(4))
+
+  (call-with-values (lambda () (values 1 2)) (lambda _ _))
+
+`string-join' now handles huge lists efficiently.
+
+`get-bytevector-some' now uses buffered input, which is much faster.
+
+Finally, `array-ref', `array-set!' on arrays of rank 1 or 2 is now
+faster, because it avoids building a rest list.  Similarly, the
+one-argument case of `array-for-each' and `array-map!' has been
+optimized, and `array-copy!' and `array-fill!' are faster.
+
+** `peek-char' no longer consumes EOF
+
+As required by the R5RS, if `peek-char' returns EOF, then the next read
+will also return EOF.  Previously `peek-char' would consume the EOF.
+This makes a difference for terminal devices where it is possible to
+read past an EOF.
+
+** Gnulib update
+
+Guile's copy of Gnulib was updated to v0.0-7865-ga828bb2.  The following
+modules were imported from Gnulib: select, times, pipe-posix, fstat,
+getlogin, poll, and c-strcase.
+
+** `include' resolves relative file names relative to including file
+
+Given a relative file name, `include' will look for it relative to the
+directory of the including file.  This harmonizes the behavior of
+`include' with that of `load'.
+
+** SLIB compatibility restored
+
+Guile 2.0.8 is now compatible with SLIB.  You will have to use a
+development version of SLIB, however, until a new version of SLIB is
+released.
+
+** Better ,trace REPL command
+
+Sometimes the ,trace output for nested function calls could overflow the
+terminal width, which wasn't useful.  Now there is a limit to the amount
+of space the prefix will take.  See the documentation for ",trace" for
+more information.
+
+** Better docstring syntax supported for `case-lambda'
+
+Docstrings can now be placed immediately after the `case-lambda' or
+`case-lambda*' keyword.  See "Case-lambda" in the manual.
+
+** Improved handling of Unicode byte order marks
+
+See "BOM Handling" in the manual for details.
+
+** Update predefined character sets to Unicode 6.2
+
+** GMP 4.2 or later required
+
+Guile used to require GMP at least version 4.1 (released in May 2002),
+and now requires at least version 4.2 (released in March 2006).
+
+* Manual updates
+
+** Better SXML documentation
+
+The documentation for SXML modules was much improved, though there is
+still far to go.  See "SXML" in manual.
+
+** Style updates
+
+Use of "iff" was replaced with standard English.  Keyword arguments are
+now documented consistently, along with their default values.
+
+** An end to the generated-documentation experiment
+
+When Guile 2.0 imported some modules from Guile-Lib, they came with a
+system that generated documentation from docstrings and module
+commentaries.  This produced terrible documentation.  We finally bit the
+bullet and incorporated these modules into the main text, and will be
+improving them manually over time, as is the case with SXML.  Help is
+appreciated.
+
+** New documentation
+
+There is now documentation for `scm_array_type', and `scm_array_ref', as
+well as for the new `array-length' / 'scm_c_array_length' /
+`scm_array_length' functions.  `array-in-bounds?' has better
+documentation as well.  The `program-arguments-alist' and
+`program-lambda-list' functions are now documented, as well as `and=>',
+`exit', and `quit'.  The (system repl server) module is now documented
+(see REPL Servers).  Finally, the GOOPS class hierarchy diagram has been
+regenerated for the web and print output formats.
+
+* New deprecations
+
+** Deprecate generalized vector interface
+
+The generalized vector interface, introduced in 1.8.0, is simply a
+redundant, verbose interface to arrays of rank 1.  `array-ref' and
+similar functions are entirely sufficient.  Thus,
+`scm_generalized_vector_p', `scm_generalized_vector_length',
+`scm_generalized_vector_ref', `scm_generalized_vector_set_x', and
+`scm_generalized_vector_to_list' are now deprecated.
+
+** Deprecate SCM_CHAR_CODE_LIMIT and char-code-limit
+
+These constants were defined to 256, which is not the highest codepoint
+supported by Guile.  Given that they were useless and incorrect, they
+have been deprecated.
+
+** Deprecate `http-get*'
+
+The new `#:streaming?' argument to `http-get' subsumes the functionality
+of `http-get*' (introduced in 2.0.7).  Also, the `#:extra-headers'
+argument is deprecated in favor of `#:headers'.
+
+** Deprecate (ice-9 mapping)
+
+This module, present in Guile since 1996 but never used or documented,
+has never worked in Guile 2.0.  It has now been deprecated and will be
+removed in Guile 2.2.
+
+** Deprecate undocumented array-related C functions
+
+These are `scm_array_fill_int', `scm_ra_eqp', `scm_ra_lessp',
+`scm_ra_leqp', `scm_ra_grp', `scm_ra_greqp', `scm_ra_sum',
+`scm_ra_product', `scm_ra_difference', `scm_ra_divide', and
+`scm_array_identity'.
+
+* New interfaces
+
+** SRFI-41 Streams
+
+See "SRFI-41" in the manual.
+
+** SRFI-45 exports `promise?'
+
+SRFI-45 now exports a `promise?' procedure that works with its promises.
+Also, its promises now print more nicely.
+
+** New HTTP client procedures
+
+See "Web Client" for documentation on the new `http-head', `http-post',
+`http-put', `http-delete', `http-trace', and `http-options' procedures,
+and also for more options to `http-get'.
+
+** Much more capable `xml->sxml'
+
+See "Reading and Writing XML" for information on how the `xml->sxml'
+parser deals with namespaces, processed entities, doctypes, and literal
+strings.  Incidentally, `current-ssax-error-port' is now a parameter
+object.
+
+** New procedures for converting strings to and from bytevectors
+
+See "Representing Strings as Bytes" for documention on the new `(ice-9
+iconv)' module and its `bytevector->string' and `string->bytevector'
+procedures.
+
+** Escape continuations with `call/ec' and `let/ec'
+
+See "Prompt Primitives".
+
+** New procedures to read all characters from a port
+
+See "Line/Delimited" in the manual for documentation on `read-string'
+ and `read-string!'.
+
+** New procedure `sendfile'
+
+See "File System".
+
+** New procedure `unget-bytevector'
+
+See "R6RS Binary Input".
+
+** New C helper: `scm_c_bind_keyword_arguments'
+
+See "Keyword Procedures".
+
+** New command-line arguments: `--language' and `-C'
+
+See "Command-line Options" in the manual.
+
+** New environment variables: `GUILE_STACK_SIZE', `GUILE_INSTALL_LOCALE'
+
+See "Environment Variables".
+
+** New procedures for dealing with file names
+
+See "File System" for documentation on `system-file-name-convention',
+`file-name-separator?', `absolute-file-name?', and
+`file-name-separator-string'.
+
+** `array-length', an array's first dimension
+
+See "Array Procedures".
+
+** `hash-count', for hash tables
+
+See "Hash Tables".
+
+** `round-ash', a bit-shifting operator that rounds on right-shift
+
+See "Bitwise Operations".
+
+** New foreign types: `ssize_t', `ptrdiff_t'
+    
+See "Foreign Types".
+
+** New C helpers: `scm_from_ptrdiff_t', `scm_to_ptrdiff_t'
+
+See "Integers".
+
+** Socket option `SO_REUSEPORT' now available from Scheme
+
+If supported on the platform, `SO_REUSEPORT' is now available from
+Scheme as well.  See "Network Sockets and Communication".
+
+** `current-language' in default environment
+
+Previously defined only in `(system base language)', `current-language'
+is now defined in the default environment, and is used to determine the
+language for the REPL, and for `compile-and-load'.
+
+** New procedure: `fluid->parameter'
+
+See "Parameters", for information on how to convert a fluid to a
+parameter.
+
+** New `print' REPL option
+
+See "REPL Commands" in the manual for information on the new
+user-customizable REPL printer.
+
+** New variable: %site-ccache-dir
+    
+The "Installing Site Packages" and "Build Config" manual sections now
+refer to this variable to describe where users should install their
+`.go' files.
+
+* Build fixes
+
+** Fix compilation against libgc 7.3.
+** Fix cross-compilation of `c-tokenize.o'.
+** Fix warning when compiling against glibc 2.17.
+** Fix documentation build against Texinfo 5.0.
+** Fix building Guile from a directory with non-ASCII characters.
+** Fix native MinGW build.
+** Fix --disable-posix build.
+** Fix MinGW builds with networking, POSIX, and thread support.
+
+* Bug fixes
+
+** Fix inexact number printer.
+   (http://bugs.gnu.org/13757)
+** Fix infinite loop when parsing optional-argument short options (SRFI-37).
+   (http://bugs.gnu.org/13176)
+** web: Support non-GMT date headers in the HTTP client.
+   (http://bugs.gnu.org/13544)
+** web: support IP-literal (IPv6 address) in Host header.
+** Avoid stack overflows with `par-map' and nested futures in general.
+   (http://bugs.gnu.org/13188)
+** Peek-char no longer consumes EOF.
+   (http://bugs.gnu.org/12216)
+** Avoid swallowing multiple EOFs in R6RS binary-input procedures.
+** A fork when multiple threads are running will now print a warning.
+** Allow for spurious wakeups from pthread_cond_wait.
+   (http://bugs.gnu.org/10641)
+** Warn and ignore module autoload failures.
+   (http://bugs.gnu.org/12202)
+** Use chmod portably in (system base compile).
+   (http://bugs.gnu.org/10474)
+** Fix response-body-port for HTTP responses without content-length.
+   (http://bugs.gnu.org/13857)
+** Allow case-lambda expressions with no clauses.
+   (http://bugs.gnu.org/9776)
+** Improve standards conformance of string->number.
+   (http://bugs.gnu.org/11887)
+** Support calls and tail-calls with more than 255 formals.
+** ,option evaluates its right-hand-side.
+   (http://bugs.gnu.org/13076)
+** Structs with tail arrays are not simple.
+   (http://bugs.gnu.org/12808)
+** Make `SCM_LONG_BIT' usable in preprocessor conditionals.
+   (http://bugs.gnu.org/13848)
+** Fix thread-unsafe lazy initializations.
+** Allow SMOB mark procedures to be called from parallel markers.
+   (http://bugs.gnu.org/13611)
+** Fix later-bindings-win logic in with-fluids.
+   (http://bugs.gnu.org/13843)
+** Fix duplicate removal of with-fluids.
+   (http://bugs.gnu.org/13838)
+** Support calling foreign functions of 10 arguments or more.
+   (http://bugs.gnu.org/13809)
+** Let reverse! accept arbitrary types as second argument.
+   (http://bugs.gnu.org/13835)
+** Recognize the `x86_64.*-gnux32' triplet.
+** Check whether a triplet's OS part specifies an ABI.
+** Recognize mips64* as having 32-bit pointers by default.
+** Use portable sed constructs.
+   (http://bugs.gnu.org/14042)
+** Remove language/glil/decompile-assembly.scm.
+   (http://bugs.gnu.org/10622)
+** Use O_BINARY in `copy-file', `load-objcode', `mkstemp'.
+** Use byte-oriented functions in `get-bytevector*'.
+** Fix abort when iconv swallows BOM from UTF-16 or UTF-32 stream.
+** Fix compilation of functions with more than 255 local variables.
+** Fix `getgroups' for when zero supplementary group IDs exist.
+** Allow (define-macro name (lambda ...)).
+** Various fixes to the (texinfo) modules.
+** guild: Gracefully handle failures to install the locale.
+** Fix format string warnings for ~!, ~|, ~/, ~q, ~Q, and ~^.
+   (http://bugs.gnu.org/13485)
+** Fix source annotation bug in psyntax 'expand-body'.
+** Ecmascript: Fix conversion to boolean for non-numbers.
+** Use case-insensitive comparisons for encoding names.
+** Add missing cond-expand feature identifiers.
+** A failure to find a module's file does not prevent future loading.
+** Many (oop goops save) fixes.
+** `http-get': don't shutdown write end of socket.
+   (http://bugs.gnu.org/13095)
+** Avoid signed integer overflow in scm_product.
+** http: read-response-body always returns bytevector or #f, never EOF.
+** web: Correctly detect "No route to host" conditions.
+** `system*': failure to execvp no longer leaks dangling processes.
+   (http://bugs.gnu.org/13166)
+** More sensible case-lambda* dispatch.
+   (http://bugs.gnu.org/12929)
+** Do not defer expansion of internal define-syntax forms.
+   (http://bugs.gnu.org/13509)
+
+
+
 Changes in 2.0.7 (since 2.0.6):
 
 * Notable changes
diff --git a/README b/README
index 31fdb80..215f9e5 100644
--- a/README
+++ b/README
@@ -62,7 +62,7 @@ Required External Packages 
================================================
 
 Guile requires the following external packages:
 
-  - GNU MP, at least version 4.1
+  - GNU MP, at least version 4.2
 
     GNU MP is used for bignum arithmetic.  It is available from
     http://gmplib.org/ .
@@ -72,7 +72,7 @@ Guile requires the following external packages:
     libltdl is used for loading extensions at run-time.  It is
     available from http://www.gnu.org/software/libtool/ .
 
-  - GNU libunistring
+  - GNU libunistring, at least version 0.9.3
 
     libunistring is used for Unicode string operations, such as the
     `utf*->string' procedures.  It is available from
diff --git a/THANKS b/THANKS
index fc2bf49..a01dcfb 100644
--- a/THANKS
+++ b/THANKS
@@ -1,7 +1,9 @@
 Contributors since the last release:
 
+           Greg Benison
         Tristan Colgate-McFarlane
         Ludovic Courtès
+          Jason Earl
           Brian Gough
          Volker Grabsch
          Julian Graham
@@ -9,8 +11,12 @@ Contributors since the last release:
          Daniel Hartwig
              No Itisnt
            Neil Jerram
+        Chris K Jester-Young
+          David Kastrup
          Daniel Kraft
+         Daniel Krueger
            Noah Lavine
+         Daniel Llorens
         Gregory Marton
       Thien-Thi Nguyen
         Han-Wen Nienhuys
@@ -21,11 +27,14 @@ Contributors since the last release:
             Ken Raeburn
         Andreas Rottmann
           Kevin Ryde
-          Brian Templeton
+       Stefan I Tampe
+             BT Templeton
+           Bake Timmons
          Mark H Weaver
           Göran Weinholt
            Ralf Wildenhues
            Andy Wingo
+            Eli Zaretskii
 
 Authors of free software libraries that have been included into Guile
 since the last release:
@@ -41,6 +50,7 @@ For fixes or providing information which led to a fix:
            Hans Åberg
           David Allouche
          Andrew Bagdanov
+          Lluís Batlle i Rossell
         Martin Baulig
         Fabrice Bauzac
         Sylvain Beucler
@@ -94,6 +104,8 @@ For fixes or providing information which led to a fix:
           David Jaquay
            Paul Jarc
           Steve Juranich
+         Nikita Karetnikov
+          David Kastrup
         Richard Kim
           Bruce Korb
            René Köcher
@@ -136,17 +148,20 @@ For fixes or providing information which led to a fix:
            Hugh Sasse
          Werner Scheinast
           Bill Schottstaedt
+            Jan Schukat
          Frank Schwidom
     John Steele Scott
          Thiemo Seufer
            Ivan Shcherbakov
           Scott Shedden
            Alex Shinn
+          Peter Simons
          Daniel Skarda
            Dale Smith
           Cesar Strauss
          Klaus Stehle
          Rainer Tammer
+        Samuel Thibault
         Richard Todd
           Issac Trotts
            Greg Troxel
@@ -164,6 +179,7 @@ For fixes or providing information which led to a fix:
          Thomas Wawrzinek
         Mark H. Weaver
           Göran Weinholt
+       David A. Wheeler
            Ralf Wildenhues
             Jon Wilson
            Andy Wingo
diff --git a/build-aux/announce-gen b/build-aux/announce-gen
index ec7c22a..3a64ec6 100755
--- a/build-aux/announce-gen
+++ b/build-aux/announce-gen
@@ -9,7 +9,7 @@ my $VERSION = '2012-06-08 06:53'; # UTC
 # If you change this file with Emacs, please let the write hook
 # do its job.  Otherwise, update this string manually.
 
-# Copyright (C) 2002-2012 Free Software Foundation, Inc.
+# Copyright (C) 2002-2013 Free Software Foundation, Inc.
 
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/build-aux/config.rpath b/build-aux/config.rpath
index 1a07018..c38b914 100755
--- a/build-aux/config.rpath
+++ b/build-aux/config.rpath
@@ -2,7 +2,7 @@
 # Output a system dependent set of variables, describing how to set the
 # run time search path of shared libraries in an executable.
 #
-#   Copyright 1996-2012 Free Software Foundation, Inc.
+#   Copyright 1996-2013 Free Software Foundation, Inc.
 #   Taken from GNU libtool, 2001
 #   Originally by Gordon Matzigkeit <address@hidden>, 1996
 #
diff --git a/build-aux/gendocs.sh b/build-aux/gendocs.sh
index 0c0bc4b..e4bfc9f 100755
--- a/build-aux/gendocs.sh
+++ b/build-aux/gendocs.sh
@@ -2,9 +2,9 @@
 # gendocs.sh -- generate a GNU manual in many formats.  This script is
 #   mentioned in maintain.texi.  See the help message below for usage details.
 
-scriptversion=2012-10-27.11
+scriptversion=2013-02-03.15
 
-# Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
+# Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
 # Free Software Foundation, Inc.
 #
 # This program is free software: you can redistribute it and/or modify
@@ -56,7 +56,7 @@ unset use_texi2html
 
 version="gendocs.sh $scriptversion
 
-Copyright 2012 Free Software Foundation, Inc.
+Copyright 2013 Free Software Foundation, Inc.
 There is NO warranty.  You may redistribute this software
 under the terms of the GNU General Public License.
 For more information about these matters, see the files named COPYING."
@@ -69,16 +69,23 @@ discussion:
   http://www.gnu.org/prep/maintain_toc.html
 
 Options:
-  -s SRCFILE  read Texinfo from SRCFILE, instead of PACKAGE.{texinfo|texi|txi}
-  -o OUTDIR   write files into OUTDIR, instead of manual/.
-  -I DIR      append DIR to the Texinfo search path.
-  --email ADR use ADR as contact in generated web pages.
-  --docbook   convert through DocBook too (xml, txt, html, pdf).
-  --html ARG  pass indicated ARG to makeinfo or texi2html for HTML targets.
-  --info ARG  pass indicated ARG to makeinfo for Info, instead of --no-split.
-  --texi2html use texi2html to generate HTML targets.
-  --help      display this help and exit successfully.
-  --version   display version information and exit successfully.
+  --email ADR use ADR as contact in generated web pages; always give this.
+
+  -s SRCFILE   read Texinfo from SRCFILE, instead of PACKAGE.{texinfo|texi|txi}
+  -o OUTDIR    write files into OUTDIR, instead of manual/.
+  -I DIR       append DIR to the Texinfo search path.
+  --common ARG pass ARG in all invocations.
+  --html ARG   pass ARG to makeinfo or texi2html for HTML targets.
+  --info ARG   pass ARG to makeinfo for Info, instead of --no-split.
+  --no-ascii   skip generating the plain text output.
+  --source ARG include ARG in tar archive of sources.
+  --split HOW  make split HTML by node, section, chapter; default node.
+
+  --texi2html  use texi2html to make HTML target, with all split versions.
+  --docbook    convert through DocBook too (xml, txt, html, pdf).
+
+  --help       display this help and exit successfully.
+  --version    display version information and exit successfully.
 
 Simple example: $prog --email address@hidden emacs \"GNU Emacs Manual\"
 
@@ -92,8 +99,8 @@ Output will be in a new subdirectory \"manual\" (by default;
 use -o OUTDIR to override).  Move all the new files into your web CVS
 tree, as explained in the Web Pages node of maintain.texi.
 
-Please do use the --email ADDRESS option to specify your bug-reporting
-address in the generated HTML pages.
+Please use the --email ADDRESS option so your own bug-reporting
+address will be used in the generated HTML pages.
 
 MANUAL-TITLE is included as part of the HTML <title> of the overall
 manual/index.html file.  It should include the name of the package being
@@ -117,7 +124,7 @@ You can set the environment variables MAKEINFO, TEXI2DVI, 
TEXI2HTML,
 and PERL to control the programs that get executed, and
 GENDOCS_TEMPLATE_DIR to control where the gendocs_template file is
 looked for.  With --docbook, the environment variables DOCBOOK2HTML,
-DOCBOOK2PDF, and DOCBOOK2TXT are also respected.
+DOCBOOK2PDF, and DOCBOOK2TXT are also consulted.
 
 By default, makeinfo and texi2dvi are run in the default (English)
 locale, since that's the language of most Texinfo manuals.  If you
@@ -130,25 +137,34 @@ Email bug reports or enhancement requests to 
address@hidden
 MANUAL_TITLE=
 PACKAGE=
 address@hidden  # please override with --email
-commonarg= # Options passed to all the tools (-I dir).
+commonarg= # passed to all makeinfo/texi2html invcations.
+dirargs=   # passed to all tools (-I dir).
 dirs=      # -I's directories.
 htmlarg=
 infoarg=--no-split
+generate_ascii=true
 outdir=manual
+source_extra=
+split=node
 srcfile=
 
 while test $# -gt 0; do
   case $1 in
-    --email) shift; EMAIL=$1;;
-    --help) echo "$usage"; exit 0;;
-    --version) echo "$version"; exit 0;;
-    -s) shift; srcfile=$1;;
-    -o) shift; outdir=$1;;
-    -I) shift; commonarg="$commonarg -I '$1'"; dirs="$dirs $1";;
-    --docbook) docbook=yes;;
-    --html) shift; htmlarg=$1;;
-    --info) shift; infoarg=$1;;
+    -s)          shift; srcfile=$1;;
+    -o)          shift; outdir=$1;;
+    -I)          shift; dirargs="$dirargs -I '$1'"; dirs="$dirs $1";;
+    --common)    shift; commonarg=$1;;
+    --docbook)   docbook=yes;;
+    --email)     shift; EMAIL=$1;;
+    --html)      shift; htmlarg=$1;;
+    --info)      shift; infoarg=$1;;
+    --no-ascii)  generate_ascii=false;;
+    --source)    shift; source_extra=$1;;
+    --split)     shift; split=$1;;
     --texi2html) use_texi2html=1;;
+
+    --help)      echo "$usage"; exit 0;;
+    --version)   echo "$version"; exit 0;;
     -*)
       echo "$0: Unknown option \`$1'." >&2
       echo "$0: Try \`--help' for more information." >&2
@@ -166,6 +182,9 @@ while test $# -gt 0; do
   shift
 done
 
+# makeinfo uses the dirargs, but texi2dvi doesn't.
+commonarg=" $dirargs $commonarg"
+
 # For most of the following, the base name is just $PACKAGE
 base=$PACKAGE
 
@@ -247,46 +266,52 @@ case $outdir in
   *)  abs_outdir=$srcdir/$outdir;;
 esac
 
-echo "Generating output formats for $srcfile"
+echo "Making output for $srcfile"
+echo " in `pwd`"
+mkdir -p "$outdir/"
 
 cmd="$SETLANG $MAKEINFO -o $PACKAGE.info $commonarg $infoarg \"$srcfile\""
-echo "Generating info file(s)... ($cmd)"
+echo "Generating info... ($cmd)"
 eval "$cmd"
-mkdir -p "$outdir/"
 tar czf "$outdir/$PACKAGE.info.tar.gz" $PACKAGE.info*
+ls -l "$outdir/$PACKAGE.info.tar.gz"
 info_tgz_size=`calcsize "$outdir/$PACKAGE.info.tar.gz"`
 # do not mv the info files, there's no point in having them available
 # separately on the web.
 
-cmd="$SETLANG $TEXI2DVI $commonarg \"$srcfile\""
-echo "Generating dvi ... ($cmd)"
+cmd="$SETLANG $TEXI2DVI $dirargs \"$srcfile\""
+printf "\nGenerating dvi... ($cmd)\n"
 eval "$cmd"
-
 # compress/finish dvi:
 gzip -f -9 $PACKAGE.dvi
 dvi_gz_size=`calcsize $PACKAGE.dvi.gz`
 mv $PACKAGE.dvi.gz "$outdir/"
+ls -l "$outdir/$PACKAGE.dvi.gz"
 
-cmd="$SETLANG $TEXI2DVI --pdf $commonarg \"$srcfile\""
-echo "Generating pdf ... ($cmd)"
+cmd="$SETLANG $TEXI2DVI --pdf $dirargs \"$srcfile\""
+printf "\nGenerating pdf... ($cmd)\n"
 eval "$cmd"
 pdf_size=`calcsize $PACKAGE.pdf`
 mv $PACKAGE.pdf "$outdir/"
+ls -l "$outdir/$PACKAGE.pdf"
 
-opt="-o $PACKAGE.txt --no-split --no-headers $commonarg"
-cmd="$SETLANG $MAKEINFO $opt \"$srcfile\""
-echo "Generating ASCII... ($cmd)"
-eval "$cmd"
-ascii_size=`calcsize $PACKAGE.txt`
-gzip -f -9 -c $PACKAGE.txt >"$outdir/$PACKAGE.txt.gz"
-ascii_gz_size=`calcsize "$outdir/$PACKAGE.txt.gz"`
-mv $PACKAGE.txt "$outdir/"
+if $generate_ascii; then
+  opt="-o $PACKAGE.txt --no-split --no-headers $commonarg"
+  cmd="$SETLANG $MAKEINFO $opt \"$srcfile\""
+  printf "\nGenerating ascii... ($cmd)\n"
+  eval "$cmd"
+  ascii_size=`calcsize $PACKAGE.txt`
+  gzip -f -9 -c $PACKAGE.txt >"$outdir/$PACKAGE.txt.gz"
+  ascii_gz_size=`calcsize "$outdir/$PACKAGE.txt.gz"`
+  mv $PACKAGE.txt "$outdir/"
+  ls -l "$outdir/$PACKAGE.txt" "$outdir/$PACKAGE.txt.gz"
+fi
 
 html_split()
 {
-  opt="--split=$1 $commonarg $htmlarg --node-files"
+  opt="--split=$1 --node-files $commonarg $htmlarg"
   cmd="$SETLANG $TEXI2HTML --output $PACKAGE.html $opt \"$srcfile\""
-  echo "Generating html by $1... ($cmd)"
+  printf "\nGenerating html by $1... ($cmd)\n"
   eval "$cmd"
   split_html_dir=$PACKAGE.html
   (
@@ -304,7 +329,7 @@ html_split()
 if test -z "$use_texi2html"; then
   opt="--no-split --html -o $PACKAGE.html $commonarg $htmlarg"
   cmd="$SETLANG $MAKEINFO $opt \"$srcfile\""
-  echo "Generating monolithic html... ($cmd)"
+  printf "\nGenerating monolithic html... ($cmd)\n"
   rm -rf $PACKAGE.html  # in case a directory is left over
   eval "$cmd"
   html_mono_size=`calcsize $PACKAGE.html`
@@ -312,24 +337,29 @@ if test -z "$use_texi2html"; then
   html_mono_gz_size=`calcsize "$outdir/$PACKAGE.html.gz"`
   copy_images "$outdir/" $PACKAGE.html
   mv $PACKAGE.html "$outdir/"
+  ls -l "$outdir/$PACKAGE.html" "$outdir/$PACKAGE.html.gz"
 
-  opt="--html -o $PACKAGE.html $commonarg $htmlarg"
+  opt="--html -o $PACKAGE.html --split=$split $commonarg $htmlarg"
   cmd="$SETLANG $MAKEINFO $opt \"$srcfile\""
-  echo "Generating html by node... ($cmd)"
+  printf "\nGenerating html by $split... ($cmd)\n"
   eval "$cmd"
   split_html_dir=$PACKAGE.html
   copy_images $split_html_dir/ $split_html_dir/*.html
   (
     cd $split_html_dir || exit 1
-    tar -czf "$abs_outdir/$PACKAGE.html_node.tar.gz" -- *
+    tar -czf "$abs_outdir/$PACKAGE.html_$split.tar.gz" -- *
   )
-  html_node_tgz_size=`calcsize "$outdir/$PACKAGE.html_node.tar.gz"`
-  rm -rf "$outdir/html_node/"
-  mv $split_html_dir "$outdir/html_node/"
-else
+  eval \
+    html_${split}_tgz_size=`calcsize "$outdir/$PACKAGE.html_$split.tar.gz"`
+  rm -rf "$outdir/html_$split/"
+  mv $split_html_dir "$outdir/html_$split/"
+  du -s "$outdir/html_$split/"
+  ls -l "$outdir/$PACKAGE.html_$split.tar.gz"
+
+else # use texi2html:
   opt="--output $PACKAGE.html $commonarg $htmlarg"
   cmd="$SETLANG $TEXI2HTML $opt \"$srcfile\""
-  echo "Generating monolithic html... ($cmd)"
+  printf "\nGenerating monolithic html with texi2html... ($cmd)\n"
   rm -rf $PACKAGE.html  # in case a directory is left over
   eval "$cmd"
   html_mono_size=`calcsize $PACKAGE.html`
@@ -342,19 +372,20 @@ else
   html_split section
 fi
 
-echo Making .tar.gz for sources...
+printf "\nMaking .tar.gz for sources...\n"
 d=`dirname $srcfile`
 (
   cd "$d"
-  srcfiles=`ls *.texinfo *.texi *.txi *.eps 2>/dev/null` || true
-  tar cvzfh "$abs_outdir/$PACKAGE.texi.tar.gz" $srcfiles
+  srcfiles=`ls -d *.texinfo *.texi *.txi *.eps $source_extra 2>/dev/null` || 
true
+  tar czfh "$abs_outdir/$PACKAGE.texi.tar.gz" $srcfiles
+  ls -l "$abs_outdir/$PACKAGE.texi.tar.gz"
 )
 texi_tgz_size=`calcsize "$outdir/$PACKAGE.texi.tar.gz"`
 
 if test -n "$docbook"; then
   opt="-o - --docbook $commonarg"
   cmd="$SETLANG $MAKEINFO $opt \"$srcfile\" >${srcdir}/$PACKAGE-db.xml"
-  echo "Generating docbook XML... ($cmd)"
+  printf "\nGenerating docbook XML... ($cmd)\n"
   eval "$cmd"
   docbook_xml_size=`calcsize $PACKAGE-db.xml`
   gzip -f -9 -c $PACKAGE-db.xml >"$outdir/$PACKAGE-db.xml.gz"
@@ -364,7 +395,7 @@ if test -n "$docbook"; then
   split_html_db_dir=html_node_db
   opt="$commonarg -o $split_html_db_dir"
   cmd="$DOCBOOK2HTML $opt \"${outdir}/$PACKAGE-db.xml\""
-  echo "Generating docbook HTML... ($cmd)"
+  printf "\nGenerating docbook HTML... ($cmd)\n"
   eval "$cmd"
   (
     cd ${split_html_db_dir} || exit 1
@@ -377,24 +408,25 @@ if test -n "$docbook"; then
   rmdir ${split_html_db_dir}
 
   cmd="$DOCBOOK2TXT \"${outdir}/$PACKAGE-db.xml\""
-  echo "Generating docbook ASCII... ($cmd)"
+  printf "\nGenerating docbook ASCII... ($cmd)\n"
   eval "$cmd"
   docbook_ascii_size=`calcsize $PACKAGE-db.txt`
   mv $PACKAGE-db.txt "$outdir/"
 
   cmd="$DOCBOOK2PDF \"${outdir}/$PACKAGE-db.xml\""
-  echo "Generating docbook PDF... ($cmd)"
+  printf "\nGenerating docbook PDF... ($cmd)\n"
   eval "$cmd"
   docbook_pdf_size=`calcsize $PACKAGE-db.pdf`
   mv $PACKAGE-db.pdf "$outdir/"
 fi
 
-echo "Writing index file..."
+printf "\nMaking index file...\n"
 if test -z "$use_texi2html"; then
-   CONDS="/%%IF  *HTML_SECTION%%/,/%%ENDIF  *HTML_SECTION%%/d;\
-          /%%IF  *HTML_CHAPTER%%/,/%%ENDIF  *HTML_CHAPTER%%/d"
+  CONDS="/%%IF  *HTML_SECTION%%/,/%%ENDIF  *HTML_SECTION%%/d;\
+         /%%IF  *HTML_CHAPTER%%/,/%%ENDIF  *HTML_CHAPTER%%/d"
 else
-   CONDS="/%%ENDIF.*%%/d;/%%IF  *HTML_SECTION%%/d;/%%IF  *HTML_CHAPTER%%/d"
+  # should take account of --split here.
+  CONDS="/%%ENDIF.*%%/d;/%%IF  *HTML_SECTION%%/d;/%%IF  *HTML_CHAPTER%%/d"
 fi
 
 curdate=`$SETLANG date '+%B %d, %Y'`
diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen
index 0b51154..223a61e 100755
--- a/build-aux/git-version-gen
+++ b/build-aux/git-version-gen
@@ -1,8 +1,8 @@
 #!/bin/sh
 # Print a version string.
-scriptversion=2012-07-06.14; # UTC
+scriptversion=2012-12-31.23; # UTC
 
-# Copyright (C) 2007-2012 Free Software Foundation, Inc.
+# Copyright (C) 2007-2013 Free Software Foundation, Inc.
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -85,16 +85,18 @@ Print a version string.
 
 Options:
 
-   --prefix     prefix of git tags to strip from version (default 'v')
-   --match      pattern for git tags to match (default: '\$prefix*')
+   --prefix           prefix of git tags (default 'v')
+   --match            pattern for git tags to match (default: '\$prefix*')
+   --fallback         fallback version to use if \"git --version\" fails
 
-   --help       display this help and exit
-   --version    output version information and exit
+   --help             display this help and exit
+   --version          output version information and exit
 
-Running without arguments will suffice in most cases.  If no --match
-argument is given, only match tags that begin with the --prefix."
+Running without arguments will suffice in most cases."
 
 prefix=v
+fallback=
+
 unset match
 unset tag_sed_script
 
@@ -104,14 +106,15 @@ while test $# -gt 0; do
     --version) echo "$version"; exit 0;;
     --prefix) shift; prefix="$1";;
     --match) shift; match="$1";;
+    --fallback) shift; fallback="$1";;
     -*)
       echo "$0: Unknown option '$1'." >&2
       echo "$0: Try '--help' for more information." >&2
       exit 1;;
     *)
-      if test -z "$tarball_version_file"; then
+      if test "x$tarball_version_file" = x; then
         tarball_version_file="$1"
-      elif test -z "$tag_sed_script"; then
+      elif test "x$tag_sed_script" = x; then
         tag_sed_script="$1"
       else
         echo "$0: extra non-option argument '$1'." >&2
@@ -121,7 +124,7 @@ while test $# -gt 0; do
   shift
 done
 
-if test -z "$tarball_version_file"; then
+if test "x$tarball_version_file" = x; then
     echo "$usage"
     exit 1
 fi
@@ -146,18 +149,19 @@ then
         [0-9]*) ;;
         *) v= ;;
     esac
-    test -z "$v" \
+    test "x$v" = x \
         && echo "$0: WARNING: $tarball_version_file is missing or damaged" 1>&2
 fi
 
-if test -n "$v"
+if test "x$v" != x
 then
     : # use $v
 # Otherwise, if there is at least one git commit involving the working
 # directory, and "git describe" output looks sensible, use that to
 # derive a version string.
 elif test "`git log -1 --pretty=format:x . 2>&1`" = x \
-    && v=`git describe --abbrev=4 --match="$match" HEAD 2>/dev/null` \
+    && v=`git describe --abbrev=4 --match="$match" HEAD 2>/dev/null \
+          || git describe --abbrev=4 HEAD 2>/dev/null` \
     && v=`printf '%s\n' "$v" | sed "$tag_sed_script"` \
     && case $v in
          $prefix[0-9]*) ;;
@@ -189,8 +193,10 @@ then
     # Remove the "g" in git describe's output string, to save a byte.
     v=`echo "$v" | sed 's/-/./;s/\(.*\)-g/\1-/'`;
     v_from_git=1
-else
+elif test "x$fallback" = x || git --version >/dev/null 2>&1; then
     v=UNKNOWN
+else
+    v=$fallback
 fi
 
 v=`echo "$v" |sed "s/^$prefix//"`
@@ -198,7 +204,7 @@ v=`echo "$v" |sed "s/^$prefix//"`
 # Test whether to append the "-dirty" suffix only if the version
 # string we're using came from git.  I.e., skip the test if it's "UNKNOWN"
 # or if it came from .tarball-version.
-if test -n "$v_from_git"; then
+if test "x$v_from_git" != x; then
   # Don't declare a version "dirty" merely because a time stamp has changed.
   git update-index --refresh > /dev/null 2>&1
 
diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog
index 5184edc..e02d34c 100755
--- a/build-aux/gitlog-to-changelog
+++ b/build-aux/gitlog-to-changelog
@@ -9,7 +9,7 @@ my $VERSION = '2012-07-29 06:11'; # UTC
 # If you change this file with Emacs, please let the write hook
 # do its job.  Otherwise, update this string manually.
 
-# Copyright (C) 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/build-aux/gnu-web-doc-update b/build-aux/gnu-web-doc-update
index 4acd69d..268ecc0 100755
--- a/build-aux/gnu-web-doc-update
+++ b/build-aux/gnu-web-doc-update
@@ -1,15 +1,10 @@
 #!/bin/sh
 # Run this after each non-alpha release, to update the web documentation at
 # http://www.gnu.org/software/$pkg/manual/
-# This script must be run from the top-level directory,
-# assumes you're using git for revision control,
-# and requires a .prev-version file as well as a Makefile,
-# from which it extracts the version number and package name, respectively.
-# Also, it assumes all documentation is in the doc/ sub-directory.
 
-VERSION=2009-07-21.16; # UTC
+VERSION=2012-12-16.14; # UTC
 
-# Copyright (C) 2009-2012 Free Software Foundation, Inc.
+# Copyright (C) 2009-2013 Free Software Foundation, Inc.
 
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -37,8 +32,14 @@ Run this script from top_srcdir (no arguments) after each 
non-alpha
 release, to update the web documentation at
 http://www.gnu.org/software/\$pkg/manual/
 
+This script assumes you're using git for revision control, and
+requires a .prev-version file as well as a Makefile, from which it
+extracts the version number and package name, respectively.  Also, it
+assumes all documentation is in the doc/ sub-directory.
+
 Options:
   -C, --builddir=DIR  location of (configured) Makefile (default: .)
+  -n, --dry-run       don't actually commit anything
   --help              print this help, then exit
   --version           print version number, then exit
 
@@ -100,12 +101,12 @@ find_tool ()
 # Requirements: everything required to bootstrap your package, plus
 # these.
 find_tool CVS cvs
-find_tool CVSU cvsu
 find_tool GIT git
 find_tool RSYNC rsync
 find_tool XARGS gxargs xargs
 
 builddir=.
+dryrun=
 while test $# != 0
 do
   # Handle --option=value by splitting apart and putting back on argv.
@@ -121,6 +122,7 @@ do
   case $1 in
     --help|--version) ${1#--};;
     -C|--builddir) shift; builddir=$1; shift ;;
+    -n|--dry-run) dryrun=echo; shift;;
     --*) die "unrecognized option: $1";;
     *) break;;
   esac
@@ -139,7 +141,7 @@ current_branch=$($GIT branch | sed -ne '/^\* /{s///;p;q;}')
 cleanup()
 {
   __st=$?
-  rm -rf "$tmp"
+  $dryrun rm -rf "$tmp"
   $GIT checkout "$current_branch"
   $GIT submodule update --recursive
   $GIT branch -d $tmp_branch
@@ -172,12 +174,15 @@ $RSYNC -avP "$builddir"/doc/manual/ $tmp/$pkg/manual
 (
   cd $tmp/$pkg/manual
 
-  # Add any new files:
-  $CVSU --types='?'                             \
-    | sed s/..//                                \
-    | $XARGS --no-run-if-empty -- $CVS add -ko
+  # Add all the files.  This is simpler than trying to add only the
+  # new ones because of new directories: it would require iterating on
+  # adding the outer directories, and then their contents.
+  #
+  # find guarantees that we add outer directories first.
+  find . -name CVS -prune -o -print             \
+    | $XARGS --no-run-if-empty -- $dryrun $CVS add -ko
 
-  $CVS ci -m $version
+  $dryrun $CVS ci -m $version
 )
 
 # Local variables:
diff --git a/build-aux/gnupload b/build-aux/gnupload
index a0e5c7b..782dd6f 100755
--- a/build-aux/gnupload
+++ b/build-aux/gnupload
@@ -1,9 +1,9 @@
 #!/bin/sh
 # Sign files and upload them.
 
-scriptversion=2012-06-11.00; # UTC
+scriptversion=2012-12-11.16; # UTC
 
-# Copyright (C) 2004-2012 Free Software Foundation, Inc.
+# Copyright (C) 2004-2013 Free Software Foundation, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -242,6 +242,8 @@ fi
 
 # Make sure passphrase is not exported in the environment.
 unset passphrase
+unset passphrase_fd_0
+GNUPGHOME=${GNUPGHOME:-$HOME/.gnupg}
 
 # Reset PATH to be sure that echo is a built-in.  We will later use
 # 'echo $passphrase' to output the passphrase, so it is important that
@@ -249,12 +251,13 @@ unset passphrase
 # listings with their arguments...).
 # Remember this script runs with 'set -e', so if echo is not built-in
 # it will exit now.
-if $dry_run; then :; else
+if $dry_run || grep -q "^use-agent" $GNUPGHOME/gpg.conf; then :; else
   PATH=/empty echo -n "Enter GPG passphrase: "
   stty -echo
   read -r passphrase
   stty echo
   echo
+  passphrase_fd_0="--passphrase-fd 0"
 fi
 
 if test $# -ne 0; then
@@ -262,7 +265,7 @@ if test $# -ne 0; then
   do
     echo "Signing $file ..."
     rm -f $file.sig
-    echo "$passphrase" | $dbg $GPG --passphrase-fd 0 -ba -o $file.sig $file
+    echo "$passphrase" | $dbg $GPG $passphrase_fd_0 -ba -o $file.sig $file
   done
 fi
 
@@ -320,12 +323,12 @@ upload ()
   case $dest in
     alpha.gnu.org:*)
       mkdirective "$destdir" "$base" "$file" "$stmt"
-      echo "$passphrase" | $dbg $GPG --passphrase-fd 0 --clearsign 
$base.directive
+      echo "$passphrase" | $dbg $GPG $passphrase_fd_0 --clearsign 
$base.directive
       $dbg ncftpput ftp-upload.gnu.org /incoming/alpha $files 
$base.directive.asc
       ;;
     ftp.gnu.org:*)
       mkdirective "$destdir" "$base" "$file" "$stmt"
-      echo "$passphrase" | $dbg $GPG --passphrase-fd 0 --clearsign 
$base.directive
+      echo "$passphrase" | $dbg $GPG $passphrase_fd_0 --clearsign 
$base.directive
       $dbg ncftpput ftp-upload.gnu.org /incoming/ftp $files $base.directive.asc
       ;;
     savannah.gnu.org:*)
@@ -344,7 +347,7 @@ upload ()
       destdir_p1=`echo "$destdir" | sed 's,^[^/]*/,,'`
       destdir_topdir=`echo "$destdir" | sed 's,/.*,,'`
       mkdirective "$destdir_p1" "$base" "$file" "$stmt"
-      echo "$passphrase" | $dbg $GPG --passphrase-fd 0 --clearsign 
$base.directive
+      echo "$passphrase" | $dbg $GPG $passphrase_fd_0 --clearsign 
$base.directive
       for f in $files $base.directive.asc
       do
         echo put $f
@@ -353,7 +356,7 @@ upload ()
     /*)
       dest_host=`echo "$dest" | sed 's,:.*,,'`
       mkdirective "$destdir" "$base" "$file" "$stmt"
-      echo "$passphrase" | $dbg $GPG --passphrase-fd 0 --clearsign 
$base.directive
+      echo "$passphrase" | $dbg $GPG $passphrase_fd_0 --clearsign 
$base.directive
       $dbg cp $files $base.directive.asc $dest_host
       ;;
     *)
diff --git a/build-aux/snippet/arg-nonnull.h b/build-aux/snippet/arg-nonnull.h
index 3a9dd26..8ea2a47 100644
--- a/build-aux/snippet/arg-nonnull.h
+++ b/build-aux/snippet/arg-nonnull.h
@@ -1,5 +1,5 @@
 /* A C macro for declaring that specific arguments must not be NULL.
-   Copyright (C) 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2009-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published
diff --git a/build-aux/snippet/c++defs.h b/build-aux/snippet/c++defs.h
index 96da94b..b35b933 100644
--- a/build-aux/snippet/c++defs.h
+++ b/build-aux/snippet/c++defs.h
@@ -1,5 +1,5 @@
 /* C++ compatible function declaration macros.
-   Copyright (C) 2010-2012 Free Software Foundation, Inc.
+   Copyright (C) 2010-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published
diff --git a/build-aux/snippet/unused-parameter.h 
b/build-aux/snippet/unused-parameter.h
index 1c8d61f..1347c27 100644
--- a/build-aux/snippet/unused-parameter.h
+++ b/build-aux/snippet/unused-parameter.h
@@ -1,5 +1,5 @@
 /* A C macro for declaring that specific function parameters are not used.
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published
diff --git a/build-aux/snippet/warn-on-use.h b/build-aux/snippet/warn-on-use.h
index d4cb94f..1736a1b 100644
--- a/build-aux/snippet/warn-on-use.h
+++ b/build-aux/snippet/warn-on-use.h
@@ -1,5 +1,5 @@
 /* A C macro for emitting warnings if a function is used.
-   Copyright (C) 2010-2012 Free Software Foundation, Inc.
+   Copyright (C) 2010-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published
@@ -55,7 +55,7 @@
    rather than issue the nice warning, but the end result of informing
    the developer about their portability problem is still achieved):
    #if HAVE_RAW_DECL_ENVIRON
-   static inline char ***rpl_environ (void) { return &environ; }
+   static char ***rpl_environ (void) { return &environ; }
    _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
    # undef environ
    # define environ (*rpl_environ ())
diff --git a/build-aux/useless-if-before-free b/build-aux/useless-if-before-free
index 2b64630..663347a 100755
--- a/build-aux/useless-if-before-free
+++ b/build-aux/useless-if-before-free
@@ -10,7 +10,7 @@ my $VERSION = '2012-01-06 07:23'; # UTC
 # If you change this file with Emacs, please let the write hook
 # do its job.  Otherwise, update this string manually.
 
-# Copyright (C) 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/build-aux/vc-list-files b/build-aux/vc-list-files
index d477da8..7ec335f 100755
--- a/build-aux/vc-list-files
+++ b/build-aux/vc-list-files
@@ -4,7 +4,7 @@
 # Print a version string.
 scriptversion=2011-05-16.22; # UTC
 
-# Copyright (C) 2006-2012 Free Software Foundation, Inc.
+# Copyright (C) 2006-2013 Free Software Foundation, Inc.
 
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
diff --git a/configure.ac b/configure.ac
index d41026d..3cbd960 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,7 +5,7 @@ dnl
 define(GUILE_CONFIGURE_COPYRIGHT,[[
 
 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-  2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+  2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
 
 This file is part of GUILE
 
@@ -35,8 +35,11 @@ AC_CONFIG_AUX_DIR([build-aux])
 AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_SRCDIR(GUILE-VERSION)
 
-dnl `AM_PROG_AR' was introduced in Automake 1.11.2.
-AM_INIT_AUTOMAKE([1.11.2 gnu no-define -Wall -Wno-override color-tests 
dist-xz])
+dnl Use `serial-tests' so the output `check-guile' is not hidden
+dnl (`parallel-tests' is the default in Automake 1.13.)
+dnl `serial-tests' was introduced in Automake 1.12.
+AM_INIT_AUTOMAKE([1.12 gnu no-define -Wall -Wno-override \
+  serial-tests color-tests dist-xz])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])], 
[AC_SUBST([AM_DEFAULT_VERBOSITY],1)])
 
 AC_COPYRIGHT(GUILE_CONFIGURE_COPYRIGHT)
@@ -644,12 +647,13 @@ AC_SUBST([SCM_I_GSC_HAVE_STRUCT_DIRENT64])
 #     this file instead of <fenv.h>
 #   process.h - mingw specific
 #   sched.h - missing on MinGW
+#   sys/sendfile.h - non-POSIX, found in glibc
 #
 AC_CHECK_HEADERS([complex.h fenv.h io.h libc.h limits.h memory.h process.h 
string.h \
 sys/dir.h sys/ioctl.h sys/select.h \
 sys/time.h sys/timeb.h sys/times.h sys/stdtypes.h sys/types.h \
 sys/utime.h time.h unistd.h utime.h pwd.h grp.h sys/utsname.h \
-direct.h machine/fpu.h poll.h sched.h])
+direct.h machine/fpu.h sched.h sys/sendfile.h])
 
 # "complex double" is new in C99, and "complex" is only a keyword if
 # <complex.h> is included
@@ -702,9 +706,6 @@ case $host in
       [Define if you have the <winsock2.h> header file.])])
     AC_CHECK_LIB(ws2_32, main)
     AC_LIBOBJ([win32-uname])
-    if test "$enable_networking" = yes ; then
-      AC_LIBOBJ([win32-socket])
-    fi
     if test "$enable_shared" = yes ; then
       EXTRA_DEFS="-DSCM_IMPORT"
       AC_DEFINE([USE_DLL_IMPORT], 1,
@@ -733,9 +734,6 @@ AC_CHECK_HEADERS([assert.h crt_externs.h])
 #               has it as an inline for chsize)
 #   ioctl - not in mingw.
 #   gmtime_r - recent posix, not on old systems
-#   pipe - not in mingw
-#   _pipe - specific to mingw, taking 3 args
-#   poll - since posix 2001
 #   readdir_r - recent posix, not on old systems
 #   readdir64_r - not available on HP-UX 11.11
 #   stat64 - SuS largefile stuff, not on old systems
@@ -745,12 +743,24 @@ AC_CHECK_HEADERS([assert.h crt_externs.h])
 #   _NSGetEnviron - Darwin specific
 #   strcoll_l, newlocale - GNU extensions (glibc), also available on Darwin
 #   fork - unavailable on Windows
-#   utimensat: posix.1-2008
-#   sched_getaffinity, sched_setaffinity: GNU extensions (glibc)
+#   utimensat - posix.1-2008
+#   sched_getaffinity, sched_setaffinity - GNU extensions (glibc)
+#   sendfile - non-POSIX, found in glibc
 #
-AC_CHECK_FUNCS([DINFINITY DQNAN cexp chsize clog clog10 ctermid fesetround 
ftime ftruncate fchown fchmod getcwd geteuid getsid gettimeofday gmtime_r ioctl 
lstat mkdir mknod nice pipe _pipe poll readdir_r readdir64_r readlink rename 
rmdir select setegid seteuid setlocale setpgid setsid sigaction siginterrupt 
stat64 strftime strptime symlink sync sysconf tcgetpgrp tcsetpgrp times uname 
waitpid strdup system usleep atexit on_exit chown link fcntl ttyname getpwent 
getgrent kill getppid getpgrp fork setitimer getitimer strchr strcmp index 
bcopy memcpy rindex truncate unsetenv isblank _NSGetEnviron strcoll strcoll_l 
newlocale utimensat sched_getaffinity sched_setaffinity])
-
-AM_CONDITIONAL([HAVE_FORK], [test "x$ac_cv_func_fork" = "xyes"])
+AC_CHECK_FUNCS([DINFINITY DQNAN cexp chsize clog clog10 ctermid                
\
+  fesetround ftime ftruncate fchown fchmod getcwd geteuid getsid       \
+  gettimeofday gmtime_r ioctl lstat mkdir mknod nice                   \
+  readdir_r readdir64_r readlink rename rmdir setegid seteuid          \
+  setlocale setpgid setsid sigaction siginterrupt stat64               \
+  strptime symlink sync sysconf tcgetpgrp tcsetpgrp uname waitpid      \
+  strdup system usleep atexit on_exit chown link fcntl ttyname getpwent        
\
+  getgrent kill getppid getpgrp fork setitimer getitimer strchr strcmp \
+  index bcopy memcpy rindex truncate unsetenv isblank _NSGetEnviron    \
+  strcoll strcoll_l newlocale utimensat sched_getaffinity              \
+  sched_setaffinity sendfile])
+
+AM_CONDITIONAL([BUILD_ICE_9_POPEN],
+  [test "x$enable_posix" = "xyes" && test "x$ac_cv_func_fork" = "xyes"])
 
 # Reasons for testing:
 #   netdb.h - not in mingw
@@ -861,6 +871,14 @@ if test "x$HAVE_LIBGMP" != "xyes"; then
   AC_MSG_ERROR([GNU MP 4.1 or greater not found, see README])
 fi
 
+dnl `mpz_inits' and `mpz_clears' appeared in GMP 5.0.0.
+save_CPPFLAGS="$CPPFLAGS"
+if test "x$LIBGMP_PREFIX" != "x"; then
+   CPPFLAGS="-I$LIBGMP_PREFIX $CPPFLAGS"
+fi
+AC_CHECK_DECLS([mpz_inits], [], [], [[#include <gmp.h>]])
+CPPFLAGS="$save_CPPFLAGS"
+
 dnl GNU libunistring is checked for by Gnulib's `libunistring' module.
 if test "x$LTLIBUNISTRING" = "x"; then
   AC_MSG_ERROR([GNU libunistring is required, please install it.])
@@ -917,6 +935,8 @@ AC_DEFUN([GUILE_FUNC_DECLARED], [
 GUILE_FUNC_DECLARED(sleep, unistd.h)
 GUILE_FUNC_DECLARED(usleep, unistd.h)
 
+AC_CHECK_DECLS([getlogin, alarm])
+
 AC_CHECK_DECLS([strptime],,,
 [#define _GNU_SOURCE /* ask glibc to give strptime prototype */
 #include <time.h>])
@@ -1226,7 +1246,13 @@ save_LIBS="$LIBS"
 LIBS="$BDW_GC_LIBS $LIBS"
 CFLAGS="$BDW_GC_CFLAGS $CFLAGS"
 
-AC_CHECK_FUNCS([GC_do_blocking GC_call_with_gc_active GC_pthread_exit 
GC_pthread_cancel GC_allow_register_threads GC_pthread_sigmask 
GC_set_start_callback GC_get_suspend_signal GC_move_disappearing_link 
GC_get_heap_usage_safe GC_get_free_space_divisor GC_gcollect_and_unmap 
GC_get_unmapped_bytes GC_set_finalizer_notifier GC_set_finalize_on_demand])
+AC_CHECK_FUNCS([GC_do_blocking GC_call_with_gc_active GC_pthread_exit  \
+  GC_pthread_cancel GC_allow_register_threads GC_pthread_sigmask       \
+  GC_set_start_callback GC_get_suspend_signal GC_move_disappearing_link        
\
+  GC_get_heap_usage_safe GC_get_free_space_divisor                     \
+  GC_gcollect_and_unmap GC_get_unmapped_bytes GC_set_finalizer_notifier        
\
+  GC_set_finalize_on_demand GC_set_all_interior_pointers GC_get_gc_no  \
+  GC_set_java_finalization])
 
 # Though the `GC_do_blocking ()' symbol is present in GC 7.1, it is not
 # declared, and has a different type (returning void instead of
@@ -1276,8 +1302,11 @@ if test $scm_cv_struct_linger = yes; then
 fi
 
 
-# On mingw, struct timespec is in <pthread.h>.
-#
+dnl Check for `struct timespec', for the sake of `gen-scmconfig'.  When
+dnl building Guile, we always have it, thanks to Gnulib; but scmconfig.h
+dnl must tell whether the system has it.
+dnl
+dnl On MinGW, struct timespec is in <pthread.h>.
 AC_MSG_CHECKING(for struct timespec)
 AC_CACHE_VAL(scm_cv_struct_timespec,
        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
@@ -1289,7 +1318,9 @@ AC_CACHE_VAL(scm_cv_struct_timespec,
           [scm_cv_struct_timespec="no"]))
 AC_MSG_RESULT($scm_cv_struct_timespec)
 if test $scm_cv_struct_timespec = yes; then
-  AC_DEFINE([HAVE_STRUCT_TIMESPEC], 1,
+  dnl Don't call it `HAVE_STRUCT_TIMESPEC' because pthread-win32's
+  dnl <pthread.h> checks whether that macro is defined.
+  AC_DEFINE([HAVE_SYSTEM_STRUCT_TIMESPEC], 1,
     [Define this if your system defines struct timespec via either <time.h> or 
<pthread.h>.])
 fi
 
@@ -1629,7 +1660,6 @@ AC_CONFIG_FILES([
 
 AC_CONFIG_FILES([meta/guile-2.2.pc])
 AC_CONFIG_FILES([meta/guile-2.2-uninstalled.pc])
-AC_CONFIG_FILES([doc/ref/effective-version.texi])
 
 GUILE_CONFIG_SCRIPT([check-guile])
 GUILE_CONFIG_SCRIPT([benchmark-guile])
diff --git a/doc/gendocs_template b/doc/gendocs_template
index a62ad61..63fbe53 100644
--- a/doc/gendocs_template
+++ b/doc/gendocs_template
@@ -75,7 +75,7 @@ the FSF.<br />
 Please send broken links and other corrections or suggestions to
 <a href="mailto:%%EMAIL%%";>&lt;%%EMAIL%%&gt;</a>.</p>
 
-<p>Copyright &copy; 2012 Free Software Foundation, Inc.</p>
+<p>Copyright &copy; 2013 Free Software Foundation, Inc.</p>
 
 <p>Verbatim copying and distribution of this entire article are
 permitted worldwide, without royalty, in any medium, provided this
diff --git a/doc/guile-api.alist b/doc/guile-api.alist
index 5830c91..78d3a5c 100644
--- a/doc/guile-api.alist
+++ b/doc/guile-api.alist
@@ -1359,7 +1359,6 @@
 (scm_array_copy_x (groups scm C) (scan-data T))
 (scm_array_dimensions (groups scm C) (scan-data T))
 (scm_array_equal_p (groups scm C) (scan-data T))
-(scm_array_fill_int (groups scm C) (scan-data T))
 (scm_array_fill_x (groups scm C) (scan-data T))
 (scm_array_for_each (groups scm C) (scan-data T))
 (scm_array_identity (groups scm C) (scan-data T))
diff --git a/doc/r5rs/r5rs.texi b/doc/r5rs/r5rs.texi
index b7722c1..775c930 100644
--- a/doc/r5rs/r5rs.texi
+++ b/doc/r5rs/r5rs.texi
@@ -106,7 +106,6 @@
 @author C. address@hidden 
 @author K. M. address@hidden 
 @author M. address@hidden 
address@hidden 
 
 
 @c  {\it Dedicated to the Memory of ALGOL 60}
@@ -116,7 +115,7 @@
 
 
 
address@hidden Summary
address@hidden Summary
 
 
 The report gives a defining description of the programming language
diff --git a/doc/ref/Makefile.am b/doc/ref/Makefile.am
index 53cc7ce..75b1745 100644
--- a/doc/ref/Makefile.am
+++ b/doc/ref/Makefile.am
@@ -123,6 +123,13 @@ autoconf-macros.texi: $(top_srcdir)/meta/guile.m4
          snarf-guile-m4-docs $(top_srcdir)/meta/guile.m4 \
          > $(srcdir)/$@
 
+# Build that file from here rather than at the user's site to avoid
+# triggering a rebuild of `guile.info'.  Note that `GUILE-VERSION' is
+# among $(CONFIG_STATUS_DEPENDENCIES); thus, when it's updated, this
+# Makefile is rebuilt, and $(GUILE_EFFECTIVE_VERSION) is up-to-date.
+$(srcdir)/effective-version.texi: $(top_srcdir)/GUILE-VERSION
+       echo "@set EFFECTIVE-VERSION $(GUILE_EFFECTIVE_VERSION)" > $@
+
 MAINTAINERCLEANFILES = autoconf-macros.texi
 
 www-commit: html
diff --git a/doc/ref/api-binding.texi b/doc/ref/api-binding.texi
index 5763f36..e3a9918 100644
--- a/doc/ref/api-binding.texi
+++ b/doc/ref/api-binding.texi
@@ -218,9 +218,9 @@ variables.
 
 @lisp
 (letrec ((a 42)
-         (b (+ a 10)))
+         (b (+ a 10)))  ;; Illegal access
   (* a b))
address@hidden ;; Error: unbound variable: a
+;; The behavior of the expression above is unspecified
 
 (letrec* ((a 42)
           (b (+ a 10)))
diff --git a/doc/ref/api-compound.texi b/doc/ref/api-compound.texi
index be3d65f..699e760 100644
--- a/doc/ref/api-compound.texi
+++ b/doc/ref/api-compound.texi
@@ -1,7 +1,7 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Guile Reference Manual.
 @c Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
address@hidden   2007, 2009, 2010, 2011, 2012  Free Software Foundation, Inc.
address@hidden   2007, 2009, 2010, 2011, 2012, 2013  Free Software Foundation, 
Inc.
 @c See the file guile.texi for copying conditions.
 
 @node Compound Data Types
@@ -22,7 +22,6 @@ values can be looked up within them.
 * Lists::                       Special list functions supported by Guile.
 * Vectors::                     One-dimensional arrays of Scheme objects.
 * Bit Vectors::                 Vectors of bits.
-* Generalized Vectors::         Treating all vector-like things uniformly.
 * Arrays::                      Matrices, etc.
 * VLists::                      Vector-like lists.
 * Record Overview::             Walking through the maze of record APIs.
@@ -301,7 +300,7 @@ depending on the datatype of their arguments.
 @rnindex list?
 @deffn {Scheme Procedure} list? x
 @deffnx {C Function} scm_list_p (x)
-Return @code{#t} iff @var{x} is a proper list, else @code{#f}.
+Return @code{#t} if @var{x} is a proper list, else @code{#f}.
 @end deffn
 
 The predicate @code{null?} is often used in list-processing code to
@@ -312,7 +311,7 @@ somehow deals with the elements of a list until the list 
satisfies
 @rnindex null?
 @deffn {Scheme Procedure} null? x
 @deffnx {C Function} scm_null_p (x)
-Return @code{#t} iff @var{x} is the empty list, else @code{#f}.
+Return @code{#t} if @var{x} is the empty list, else @code{#f}.
 @end deffn
 
 @deftypefn {C Function} int scm_is_null (SCM x)
@@ -993,9 +992,8 @@ are displayed as a sequence of @code{0}s and @code{1}s 
prefixed by
 #*00000000
 @end example
 
-Bit vectors are also generalized vectors, @xref{Generalized
-Vectors}, and can thus be used with the array procedures, @xref{Arrays}.
-Bit vectors are the special case of one dimensional bit arrays.
+Bit vectors are the special case of one dimensional bit arrays, and can
+thus be used with the array procedures, @xref{Arrays}.
 
 @deffn {Scheme Procedure} bitvector? obj
 @deffnx {C Function} scm_bitvector_p (obj)
@@ -1163,74 +1161,6 @@ Like @code{scm_bitvector_elements}, but the pointer is 
good for reading
 and writing.
 @end deftypefn
 
address@hidden Generalized Vectors
address@hidden Generalized Vectors
-
-Guile has a number of data types that are generally vector-like:
-strings, uniform numeric vectors, bytevectors, bitvectors, and of course
-ordinary vectors of arbitrary Scheme values.  These types are disjoint:
-a Scheme value belongs to at most one of the five types listed above.
-
-If you want to gloss over this distinction and want to treat all four
-types with common code, you can use the procedures in this section.
-They work with the @emph{generalized vector} type, which is the union
-of the five vector-like types.
-
address@hidden {Scheme Procedure} generalized-vector? obj
address@hidden {C Function} scm_generalized_vector_p (obj)
-Return @code{#t} if @var{obj} is a vector, bytevector, string,
-bitvector, or uniform numeric vector.
address@hidden deffn
-
address@hidden {Scheme Procedure} generalized-vector-length v
address@hidden {C Function} scm_generalized_vector_length (v)
-Return the length of the generalized vector @var{v}.
address@hidden deffn
-
address@hidden {Scheme Procedure} generalized-vector-ref v idx
address@hidden {C Function} scm_generalized_vector_ref (v, idx)
-Return the element at index @var{idx} of the
-generalized vector @var{v}.
address@hidden deffn
-
address@hidden {Scheme Procedure} generalized-vector-set! v idx val
address@hidden {C Function} scm_generalized_vector_set_x (v, idx, val)
-Set the element at index @var{idx} of the
-generalized vector @var{v} to @var{val}.
address@hidden deffn
-
address@hidden {Scheme Procedure} generalized-vector->list v
address@hidden {C Function} scm_generalized_vector_to_list (v)
-Return a new list whose elements are the elements of the
-generalized vector @var{v}.
address@hidden deffn
-
address@hidden {C Function} int scm_is_generalized_vector (SCM obj)
-Return @code{1} if @var{obj} is a vector, string,
-bitvector, or uniform numeric vector; else return @code{0}.
address@hidden deftypefn
-
address@hidden {C Function} size_t scm_c_generalized_vector_length (SCM v)
-Return the length of the generalized vector @var{v}.
address@hidden deftypefn
-
address@hidden {C Function} SCM scm_c_generalized_vector_ref (SCM v, size_t idx)
-Return the element at index @var{idx} of the generalized vector @var{v}.
address@hidden deftypefn
-
address@hidden {C Function} void scm_c_generalized_vector_set_x (SCM v, size_t 
idx, SCM val)
-Set the element at index @var{idx} of the generalized vector @var{v}
-to @var{val}.
address@hidden deftypefn
-
address@hidden {C Function} void scm_generalized_vector_get_handle (SCM v, 
scm_t_array_handle *handle)
-Like @code{scm_array_get_handle} but an error is signalled when @var{v}
-is not of rank one.  You can use @code{scm_array_handle_ref} and
address@hidden to read and write the elements of @var{v},
-or you can use functions like @code{scm_array_handle_<foo>_elements} to
-deal with specific types of vectors.
address@hidden deftypefn
-
 @node Arrays
 @subsection Arrays
 @tpindex Arrays
@@ -1239,13 +1169,13 @@ deal with specific types of vectors.
 number of dimensions.  Each cell can be accessed in constant time by
 supplying an index for each dimension.
 
-In the current implementation, an array uses a generalized vector for
-the actual storage of its elements.  Any kind of generalized vector
-will do, so you can have arrays of uniform numeric values, arrays of
-characters, arrays of bits, and of course, arrays of arbitrary Scheme
-values.  For example, arrays with an underlying @code{c64vector} might
-be nice for digital signal processing, while arrays made from a
address@hidden might be used to hold gray-scale images.
+In the current implementation, an array uses a vector of some kind for
+the actual storage of its elements.  Any kind of vector will do, so you
+can have arrays of uniform numeric values, arrays of characters, arrays
+of bits, and of course, arrays of arbitrary Scheme values.  For example,
+arrays with an underlying @code{c64vector} might be nice for digital
+signal processing, while arrays made from a @code{u8vector} might be
+used to hold gray-scale images.
 
 The number of dimensions of an array is called its @dfn{rank}.  Thus,
 a matrix is an array of rank 2, while a vector has rank 1.  When
@@ -1267,9 +1197,9 @@ matrix with zero columns and 3 rows is different from a 
matrix with 3
 columns and zero rows, which again is different from a vector of
 length zero.
 
-Generalized vectors, such as strings, uniform numeric vectors,
-bytevectors, bit vectors and ordinary vectors, are the special case of
-one dimensional arrays.
+The array procedures are all polymorphic, treating strings, uniform
+numeric vectors, bytevectors, bit vectors and ordinary vectors as one
+dimensional arrays.
 
 @menu
 * Array Syntax::                
@@ -1462,6 +1392,7 @@ as elements in the list.
 @end deffn
 
 @deffn {Scheme Procedure} array-type array
address@hidden {C Function} scm_array_type (array)
 Return the type of @var{array}.  This is the `vectag' used for
 printing @var{array} (or @code{#t} for ordinary arrays) and can be
 used with @code{make-typed-array} to create an array of the same kind
@@ -1469,6 +1400,7 @@ as @var{array}.
 @end deffn
 
 @deffn {Scheme Procedure} array-ref array idx @dots{}
address@hidden {C Function} scm_array_ref (array, idxlist)
 Return the element at @code{(idx @dots{})} in @var{array}.
 
 @example
@@ -1479,7 +1411,7 @@ Return the element at @code{(idx @dots{})} in @var{array}.
 
 @deffn {Scheme Procedure} array-in-bounds? array idx @dots{}
 @deffnx {C Function} scm_array_in_bounds_p (array, idxlist)
-Return @code{#t} if the given index would be acceptable to
+Return @code{#t} if the given indices would be acceptable to
 @code{array-ref}.
 
 @example
@@ -1520,6 +1452,13 @@ For example,
 @end example
 @end deffn
 
address@hidden {Scheme Procedure} array-length array
address@hidden {C Function} scm_array_length (array)
address@hidden {C Function} size_t scm_c_array_length (array)
+Return the length of an array: its first dimension. It is an error to
+ask for the length of an array of rank 0.
address@hidden deffn
+
 @deffn {Scheme Procedure} array-rank array
 @deffnx {C Function} scm_array_rank (array)
 Return the rank of @var{array}.
@@ -2272,9 +2211,9 @@ different trade-offs.  Over the years, each ``standard'' 
has also come
 with its own new record interface, leading to a maze of record APIs.
 
 At the highest level is SRFI-9, a high-level record interface
-implemented by most Scheme implementations (@pxref{SRFI-9}).  It defines
-a simple and efficient syntactic abstraction of record types and their
-associated type predicate, fields, and field accessors.  SRFI-9 is
+implemented by most Scheme implementations (@pxref{SRFI-9 Records}).  It
+defines a simple and efficient syntactic abstraction of record types and
+their associated type predicate, fields, and field accessors.  SRFI-9 is
 suitable for most uses, and this is the recommended way to create record
 types in Guile.  Similar high-level record APIs include SRFI-35
 (@pxref{SRFI-35}) and R6RS records (@pxref{rnrs records syntactic}).
@@ -2309,7 +2248,7 @@ Overview}).  It can be used with:
 (use-modules (srfi srfi-9))
 @end example
 
address@hidden {library syntax} define-record-type type @* (constructor 
fieldname @dots{}) @* predicate @* (fieldname accessor [modifier]) @dots{}
address@hidden {Scheme Syntax} define-record-type type @* (constructor 
fieldname @dots{}) @* predicate @* (fieldname accessor [modifier]) @dots{}
 @sp 1
 Create a new record type, and make various @code{define}s for using
 it.  This syntax can only occur at the top-level, not nested within
@@ -2344,12 +2283,12 @@ field in a @var{record}.
 An example will illustrate typical usage,
 
 @example
-(define-record-type employee-type
+(define-record-type <employee>
   (make-employee name age salary)
   employee?
-  (name    get-employee-name)
-  (age     get-employee-age    set-employee-age)
-  (salary  get-employee-salary set-employee-salary))
+  (name    employee-name)
+  (age     employee-age    set-employee-age!)
+  (salary  employee-salary set-employee-salary!))
 @end example
 
 This creates a new employee data type, with name, age and salary
@@ -2359,13 +2298,13 @@ that it's established only when an employee object is 
created).  These
 can all then be used as for example,
 
 @example
-employee-type @result{} #<record-type employee-type>
+<employee> @result{} #<record-type <employee>>
 
 (define fred (make-employee "Fred" 45 20000.00))
 
 (employee? fred)        @result{} #t
-(get-employee-age fred) @result{} 45
-(set-employee-salary fred 25000.00)  ;; pay rise
+(employee-age fred)     @result{} 45
+(set-employee-salary! fred 25000.00)  ;; pay rise
 @end example
 
 The functions created by @code{define-record-type} are ordinary
@@ -2395,10 +2334,10 @@ an output port.
 This example prints the employee's name in brackets, for instance 
@code{[Fred]}.
 
 @example
-(set-record-type-printer! employee-type
+(set-record-type-printer! <employee>
   (lambda (record port)
     (write-char #\[ port)
-    (display (get-employee-name record) port)
+    (display (employee-name record) port)
     (write-char #\] port)))
 @end example
 
@@ -2512,7 +2451,7 @@ data type.  A @dfn{record} is an instance of a record 
type.
 
 Note that in many ways, this interface is too low-level for every-day
 use.  Most uses of records are better served by SRFI-9 records.
address@hidden
address@hidden Records}.
 
 @deffn {Scheme Procedure} record? obj
 Return @code{#t} if @var{obj} is a record of any type and @code{#f}
@@ -3796,8 +3735,9 @@ key is not found.
 #f
 @end lisp
 
-There is no procedure for calculating the number of key/value-pairs in
-a hash table, but @code{hash-fold} can be used for doing exactly that.
+Interesting results can be computed by using @code{hash-fold} to work
+through each element.  This example will count the total number of
+elements:
 
 @lisp
 (hash-fold (lambda (key value seed) (+ 1 seed)) 0 h)
@@ -3805,6 +3745,24 @@ a hash table, but @code{hash-fold} can be used for doing 
exactly that.
 3
 @end lisp
 
+The same thing can be done with the procedure @code{hash-count}, which
+can also count the number of elements matching a particular predicate.
+For example, count the number of elements with string values:
+
address@hidden
+(hash-count (lambda (key value) (string? value)) h)
address@hidden
+2
address@hidden lisp
+
+Counting all the elements is a simple task using @code{const}:
+
address@hidden
+(hash-count (const #t) h)
address@hidden
+3
address@hidden lisp
+
 @node Hash Table Reference
 @subsubsection Hash Table Reference
 
@@ -4032,6 +3990,13 @@ For example, the following returns a count of how many 
keys in
 @end example
 @end deffn
 
address@hidden {Scheme Procedure} hash-count pred table
address@hidden {C Function} scm_hash_count (pred, table)
+Return the number of elements in the given hash @var{table} that cause
address@hidden(@var{pred} @var{key} @var{value})} to return true.  To quickly
+determine the total number of elements, use @code{(const #t)} for
address@hidden
address@hidden deffn
 
 @c Local Variables:
 @c TeX-master: "guile.texi"
diff --git a/doc/ref/api-control.texi b/doc/ref/api-control.texi
index d8b6a45..f34074e 100644
--- a/doc/ref/api-control.texi
+++ b/doc/ref/api-control.texi
@@ -1,7 +1,7 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Guile Reference Manual.
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2009, 
2010, 2011, 2012
address@hidden   Free Software Foundation, Inc.
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2009, 
2010,
address@hidden   2011, 2012, 2013 Free Software Foundation, Inc.
 @c See the file guile.texi for copying conditions.
 
 @node Control Mechanisms
@@ -200,7 +200,7 @@ For this clause type, @var{test} may return multiple 
values, and
 @code{cond} ignores its boolean state; instead, @code{cond} evaluates
 @var{guard} and applies the resulting procedure to the value(s) of
 @var{test}, as if @var{guard} were the @var{consumer} argument of
address@hidden  Iff the result of that procedure call is a
address@hidden  If the result of that procedure call is a
 true value, it evaluates @var{expression} and applies the resulting
 procedure to the value(s) of @var{test}, in the same manner as the
 @var{guard} was called.
@@ -577,9 +577,58 @@ both.
 
 Before moving on, we should mention that if the handler of a prompt is a
 @code{lambda} expression, and the first argument isn't referenced, an abort to
-that prompt will not cause a continuation to be reified. This can be an
+that prompt will not cause a continuation to be reified.  This can be an
 important efficiency consideration to keep in mind.
 
address@hidden continuation, escape
+One example where this optimization matters is @dfn{escape
+continuations}.  Escape continuations are delimited continuations whose
+only use is to make a non-local exit---i.e., to escape from the current
+continuation.  Such continuations are invoked only once, and for this
+reason they are sometimes called @dfn{one-shot continuations}.  A common
+use of escape continuations is when throwing an exception
+(@pxref{Exceptions}).
+
+The constructs below are syntactic sugar atop prompts to simplify the
+use of escape continuations.
+
address@hidden {Scheme Procedure} call-with-escape-continuation proc
address@hidden {Scheme Procedure} call/ec proc
+Call @var{proc} with an escape continuation.
+
+In the example below, the @var{return} continuation is used to escape
+the continuation of the call to @code{fold}.
+
address@hidden
+(use-modules (ice-9 control)
+             (srfi srfi-1))
+
+(define (prefix x lst)
+  ;; Return all the elements before the first occurrence
+  ;; of X in LST.
+  (call/ec
+    (lambda (return)
+      (fold (lambda (element prefix)
+              (if (equal? element x)
+                  (return (reverse prefix))  ; escape `fold'
+                  (cons element prefix)))
+            '()
+            lst))))
+
+(prefix 'a '(0 1 2 a 3 4 5))
address@hidden (0 1 2)
address@hidden lisp
address@hidden deffn
+
address@hidden {Scheme Syntax} let-escape-continuation k body @dots{}
address@hidden {Scheme Syntax} let/ec k body @dots{}
+Bind @var{k} within @var{body} to an escape continuation.
+
+This is equivalent to
address@hidden(call/ec (lambda (@var{k}) @var{body} @dots{}))}.
address@hidden deffn
+
+
 @node Shift and Reset
 @subsubsection Shift, Reset, and All That
 
@@ -987,6 +1036,11 @@ to avoid the risk of confusion with POSIX signals.
 This manual prefers to speak of throwing and catching exceptions, since
 this terminology matches the corresponding Guile primitives.
 
+The exception mechanism described in this section has connections with
address@hidden continuations} (@pxref{Prompts}).  In particular,
+throwing an exception is akin to invoking an @dfn{escape continuation}
+(@pxref{Prompt Primitives, @code{call/ec}}).
+
 
 @node Catch
 @subsubsection Catching Exceptions
@@ -1735,8 +1789,8 @@ and the call to these routines doesn't change 
@code{errno}.
 @deftypefnx {C Function} void scm_wrong_type_arg (char address@hidden, int 
@var{argnum}, SCM @var{bad_value})
 @deftypefnx {C Function} void scm_wrong_type_arg_msg (char address@hidden, int 
@var{argnum}, SCM @var{bad_value}, const char address@hidden)
 @deftypefnx {C Function} void scm_memory_error (char address@hidden)
-Throw an error with the various keys described above.
 @deftypefnx {C Function} void scm_misc_error (const char address@hidden, const 
char address@hidden, SCM @var{args})
+Throw an error with the various keys described above.
 
 In @code{scm_wrong_num_args}, @var{proc} should be a Scheme symbol
 which is the name of the procedure incorrectly invoked.  The other
diff --git a/doc/ref/api-data.texi b/doc/ref/api-data.texi
index 28160c8..7603180 100644
--- a/doc/ref/api-data.texi
+++ b/doc/ref/api-data.texi
@@ -1,7 +1,7 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Guile Reference Manual.
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2006, 
2007, 2008, 2009, 2010, 2011, 2012, 2013
address@hidden   Free Software Foundation, Inc.
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2006, 
2007,
address@hidden   2008, 2009, 2010, 2011, 2012, 2013  Free Software Foundation, 
Inc.
 @c See the file guile.texi for copying conditions.
 
 @node Simple Data Types
@@ -414,6 +414,7 @@ function will always succeed and will always return an 
exact number.
 @deftypefnx {C Function} {unsigned long long} scm_to_ulong_long (SCM x)
 @deftypefnx {C Function} size_t scm_to_size_t (SCM x)
 @deftypefnx {C Function} ssize_t scm_to_ssize_t (SCM x)
address@hidden {C Function} scm_t_ptrdiff scm_to_ptrdiff_t (SCM x)
 @deftypefnx {C Function} scm_t_int8 scm_to_int8 (SCM x)
 @deftypefnx {C Function} scm_t_uint8 scm_to_uint8 (SCM x)
 @deftypefnx {C Function} scm_t_int16 scm_to_int16 (SCM x)
@@ -447,6 +448,7 @@ the corresponding types are.
 @deftypefnx {C Function} SCM scm_from_ulong_long (unsigned long long x)
 @deftypefnx {C Function} SCM scm_from_size_t (size_t x)
 @deftypefnx {C Function} SCM scm_from_ssize_t (ssize_t x)
address@hidden {C Function} SCM scm_from_ptrdiff_t (scm_t_ptrdiff x)
 @deftypefnx {C Function} SCM scm_from_int8 (scm_t_int8 x)
 @deftypefnx {C Function} SCM scm_from_uint8 (scm_t_uint8 x)
 @deftypefnx {C Function} SCM scm_from_int16 (scm_t_int16 x)
@@ -1684,19 +1686,15 @@ starts from 0 for the least significant bit.
 @end lisp
 @end deffn
 
address@hidden {Scheme Procedure} ash n cnt
address@hidden {C Function} scm_ash (n, cnt)
-Return @var{n} shifted left by @var{cnt} bits, or shifted right if
address@hidden is negative.  This is an ``arithmetic'' shift.
address@hidden {Scheme Procedure} ash n count
address@hidden {C Function} scm_ash (n, count)
+Return @math{floor(n * 2^count)}.
address@hidden and @var{count} must be exact integers.
 
-This is effectively a multiplication by @m{2^{cnt}, address@hidden, and
-when @var{cnt} is negative it's a division, rounded towards negative
-infinity.  (Note that this is not the same rounding as @code{quotient}
-does.)
-
-With @var{n} viewed as an infinite precision twos complement,
address@hidden means a left shift introducing zero bits, or a right shift
-dropping bits.
+With @var{n} viewed as an infinite-precision twos-complement
+integer, @code{ash} means a left shift introducing zero bits
+when @var{count} is positive, or a right shift dropping bits
+when @var{count} is negative.  This is an ``arithmetic'' shift.
 
 @lisp
 (number->string (ash #b1 3) 2)     @result{} "1000"
@@ -1707,6 +1705,28 @@ dropping bits.
 @end lisp
 @end deffn
 
address@hidden {Scheme Procedure} round-ash n count
address@hidden {C Function} scm_round_ash (n, count)
+Return @math{round(n * 2^count)}.
address@hidden and @var{count} must be exact integers.
+
+With @var{n} viewed as an infinite-precision twos-complement
+integer, @code{round-ash} means a left shift introducing zero
+bits when @var{count} is positive, or a right shift rounding
+to the nearest integer (with ties going to the nearest even
+integer) when @var{count} is negative.  This is a rounded
+``arithmetic'' shift.
+
address@hidden
+(number->string (round-ash #b1 3) 2)     @result{} \"1000\"
+(number->string (round-ash #b1010 -1) 2) @result{} \"101\"
+(number->string (round-ash #b1010 -2) 2) @result{} \"10\"
+(number->string (round-ash #b1011 -2) 2) @result{} \"11\"
+(number->string (round-ash #b1101 -2) 2) @result{} \"11\"
+(number->string (round-ash #b1110 -2) 2) @result{} \"100\"
address@hidden lisp
address@hidden deffn
+
 @deffn {Scheme Procedure} logcount n
 @deffnx {C Function} scm_logcount (n)
 Return the number of bits in integer @var{n}.  If @var{n} is
@@ -2047,7 +2067,7 @@ number of one to eight digits.
 @rnindex char?
 @deffn {Scheme Procedure} char? x
 @deffnx {C Function} scm_char_p (x)
-Return @code{#t} iff @var{x} is a character, else @code{#f}.
+Return @code{#t} if @var{x} is a character, else @code{#f}.
 @end deffn
 
 Fundamentally, the character comparison operations below are
@@ -2055,31 +2075,31 @@ numeric comparisons of the character's code points.
 
 @rnindex char=?
 @deffn {Scheme Procedure} char=? x y
-Return @code{#t} iff code point of @var{x} is equal to the code point
+Return @code{#t} if code point of @var{x} is equal to the code point
 of @var{y}, else @code{#f}.
 @end deffn
 
 @rnindex char<?
 @deffn {Scheme Procedure} char<? x y
-Return @code{#t} iff the code point of @var{x} is less than the code
+Return @code{#t} if the code point of @var{x} is less than the code
 point of @var{y}, else @code{#f}.
 @end deffn
 
 @rnindex char<=?
 @deffn {Scheme Procedure} char<=? x y
-Return @code{#t} iff the code point of @var{x} is less than or equal
+Return @code{#t} if the code point of @var{x} is less than or equal
 to the code point of @var{y}, else @code{#f}.
 @end deffn
 
 @rnindex char>?
 @deffn {Scheme Procedure} char>? x y
-Return @code{#t} iff the code point of @var{x} is greater than the
+Return @code{#t} if the code point of @var{x} is greater than the
 code point of @var{y}, else @code{#f}.
 @end deffn
 
 @rnindex char>=?
 @deffn {Scheme Procedure} char>=? x y
-Return @code{#t} iff the code point of @var{x} is greater than or
+Return @code{#t} if the code point of @var{x} is greater than or
 equal to the code point of @var{y}, else @code{#f}.
 @end deffn
 
@@ -2097,32 +2117,32 @@ it cannot cover all cases for all languages.
 
 @rnindex char-ci=?
 @deffn {Scheme Procedure} char-ci=? x y
-Return @code{#t} iff the case-folded code point of @var{x} is the same
+Return @code{#t} if the case-folded code point of @var{x} is the same
 as the case-folded code point of @var{y}, else @code{#f}.
 @end deffn
 
 @rnindex char-ci<?
 @deffn {Scheme Procedure} char-ci<? x y
-Return @code{#t} iff the case-folded code point of @var{x} is less
+Return @code{#t} if the case-folded code point of @var{x} is less
 than the case-folded code point of @var{y}, else @code{#f}.
 @end deffn
 
 @rnindex char-ci<=?
 @deffn {Scheme Procedure} char-ci<=? x y
-Return @code{#t} iff the case-folded code point of @var{x} is less
+Return @code{#t} if the case-folded code point of @var{x} is less
 than or equal to the case-folded code point of @var{y}, else
 @code{#f}.
 @end deffn
 
 @rnindex char-ci>?
 @deffn {Scheme Procedure} char-ci>? x y
-Return @code{#t} iff the case-folded code point of @var{x} is greater
+Return @code{#t} if the case-folded code point of @var{x} is greater
 than the case-folded code point of @var{y}, else @code{#f}.
 @end deffn
 
 @rnindex char-ci>=?
 @deffn {Scheme Procedure} char-ci>=? x y
-Return @code{#t} iff the case-folded code point of @var{x} is greater
+Return @code{#t} if the case-folded code point of @var{x} is greater
 than or equal to the case-folded code point of @var{y}, else
 @code{#f}.
 @end deffn
@@ -2130,36 +2150,36 @@ than or equal to the case-folded code point of @var{y}, 
else
 @rnindex char-alphabetic?
 @deffn {Scheme Procedure} char-alphabetic? chr
 @deffnx {C Function} scm_char_alphabetic_p (chr)
-Return @code{#t} iff @var{chr} is alphabetic, else @code{#f}.
+Return @code{#t} if @var{chr} is alphabetic, else @code{#f}.
 @end deffn
 
 @rnindex char-numeric?
 @deffn {Scheme Procedure} char-numeric? chr
 @deffnx {C Function} scm_char_numeric_p (chr)
-Return @code{#t} iff @var{chr} is numeric, else @code{#f}.
+Return @code{#t} if @var{chr} is numeric, else @code{#f}.
 @end deffn
 
 @rnindex char-whitespace?
 @deffn {Scheme Procedure} char-whitespace? chr
 @deffnx {C Function} scm_char_whitespace_p (chr)
-Return @code{#t} iff @var{chr} is whitespace, else @code{#f}.
+Return @code{#t} if @var{chr} is whitespace, else @code{#f}.
 @end deffn
 
 @rnindex char-upper-case?
 @deffn {Scheme Procedure} char-upper-case? chr
 @deffnx {C Function} scm_char_upper_case_p (chr)
-Return @code{#t} iff @var{chr} is uppercase, else @code{#f}.
+Return @code{#t} if @var{chr} is uppercase, else @code{#f}.
 @end deffn
 
 @rnindex char-lower-case?
 @deffn {Scheme Procedure} char-lower-case? chr
 @deffnx {C Function} scm_char_lower_case_p (chr)
-Return @code{#t} iff @var{chr} is lowercase, else @code{#f}.
+Return @code{#t} if @var{chr} is lowercase, else @code{#f}.
 @end deffn
 
 @deffn {Scheme Procedure} char-is-both? chr
 @deffnx {C Function} scm_char_is_both_p (chr)
-Return @code{#t} iff @var{chr} is either uppercase or lowercase, else
+Return @code{#t} if @var{chr} is either uppercase or lowercase, else
 @code{#f}.
 @end deffn
 
@@ -2581,8 +2601,8 @@ string is not defined.
 
 @deffn {Scheme Procedure} char-set-contains? cs ch
 @deffnx {C Function} scm_char_set_contains_p (cs, ch)
-Return @code{#t} iff the character @var{ch} is contained in the
-character set @var{cs}.
+Return @code{#t} if the character @var{ch} is contained in the
+character set @var{cs}, or @code{#f} otherwise.
 @end deffn
 
 @deffn {Scheme Procedure} char-set-every pred cs
@@ -3128,7 +3148,7 @@ placed between the strings, and defaults to the symbol
 @item infix
 Insert the separator between list elements.  An empty string
 will produce an empty list.
address@hidden string-infix
address@hidden strict-infix
 Like @code{infix}, but will raise an error if given the empty
 list.
 @item suffix
@@ -4202,7 +4222,7 @@ Unlike the rest of the procedures in this section, you 
have to load the
 (use-modules (ice-9 iconv))
 @end example
 
address@hidden string->bytevector string encoding [conversion-strategy]
address@hidden {Scheme Procedure} string->bytevector string encoding 
[conversion-strategy]
 Encode @var{string} as a sequence of bytes.
 
 The string will be encoded in the character set specified by the
@@ -4216,7 +4236,7 @@ bytevectors.  @xref{Ports}, for more on character 
encodings and
 conversion strategies.
 @end deffn
 
address@hidden bytevector->string bytevector encoding [conversion-strategy]
address@hidden {Scheme Procedure} bytevector->string bytevector encoding 
[conversion-strategy]
 Decode @var{bytevector} into a string.
 
 The bytes will be decoded from the character set by the @var{encoding}
@@ -4227,7 +4247,7 @@ argument to modify this behavior.  @xref{Ports}, for more 
on character
 encodings and conversion strategies.
 @end deffn
 
address@hidden call-with-output-encoded-string encoding proc 
[conversion-strategy]
address@hidden {Scheme Procedure} call-with-output-encoded-string encoding proc 
[conversion-strategy]
 Like @code{call-with-output-string}, but instead of returning a string,
 returns a encoding of the string according to @var{encoding}, as a
 bytevector.  This procedure can be more efficient than collecting a
@@ -4283,9 +4303,9 @@ If the C string is ill-formed, an error will be raised.
 
 Note that these functions should @emph{not} be used to convert C string
 constants, because there is no guarantee that the current locale will
-match that of the source code.  To convert C string constants, use
address@hidden, @code{scm_from_utf8_string} or
address@hidden
+match that of the execution character set, used for string and character
+constants.  Most modern C compilers use UTF-8 by default, so to convert
+C string constants we recommend @code{scm_from_utf8_string}.
 @end deftypefn
 
 @deftypefn  {C Function} SCM scm_take_locale_string (char *str)
@@ -4548,7 +4568,7 @@ R6RS (@pxref{R6RS I/O Ports}).
 * Bytevectors and Integer Lists::  Converting to/from an integer list.
 * Bytevectors as Floats::       Interpreting bytes as real numbers.
 * Bytevectors as Strings::      Interpreting bytes as Unicode strings.
-* Bytevectors as Generalized Vectors::  Guile extension to the bytevector API.
+* Bytevectors as Arrays::       Guile extension to the bytevector API.
 * Bytevectors as Uniform Vectors::  Bytevectors and SRFI-4.
 @end menu
 
@@ -4934,25 +4954,27 @@ or UTF-32-decoded contents of bytevector @var{utf}.  
For UTF-16 and UTF-32,
 it defaults to big endian.
 @end deffn
 
address@hidden Bytevectors as Generalized Vectors
address@hidden Accessing Bytevectors with the Generalized Vector API
address@hidden Bytevectors as Arrays
address@hidden Accessing Bytevectors with the Array API
 
 As an extension to the R6RS, Guile allows bytevectors to be manipulated
-with the @dfn{generalized vector} procedures (@pxref{Generalized
-Vectors}).  This also allows bytevectors to be accessed using the
-generic @dfn{array} procedures (@pxref{Array Procedures}).  When using
-these APIs, bytes are accessed one at a time as 8-bit unsigned integers:
+with the @dfn{array} procedures (@pxref{Arrays}).  When using these
+APIs, bytes are accessed one at a time as 8-bit unsigned integers:
 
 @example
 (define bv #vu8(0 1 2 3))
 
-(generalized-vector? bv)
+(array? bv)
 @result{} #t
 
-(generalized-vector-ref bv 2)
+(array-rank bv)
address@hidden 1
+
+(array-ref bv 2)
 @result{} 2
 
-(generalized-vector-set! bv 2 77)
+;; Note the different argument order on array-set!.
+(array-set! bv 77 2)
 (array-ref bv 2)
 @result{} 77
 
@@ -5353,15 +5375,15 @@ When you want to do more from C, you should convert 
between symbols
 and strings using @code{scm_symbol_to_string} and
 @code{scm_string_to_symbol} and work with the strings.
 
address@hidden {C Function} scm_from_latin1_symbol (const char *name)
address@hidden {C Function} scm_from_utf8_symbol (const char *name)
address@hidden {C Function} SCM scm_from_latin1_symbol (const char *name)
address@hidden {C Function} SCM scm_from_utf8_symbol (const char *name)
 Construct and return a Scheme symbol whose name is specified by the
 null-terminated C string @var{name}.  These are appropriate when
 the C string is hard-coded in the source code.
 @end deftypefn
 
address@hidden {C Function} scm_from_locale_symbol (const char *name)
address@hidden {C Function} scm_from_locale_symboln (const char *name, size_t 
len)
address@hidden {C Function} SCM scm_from_locale_symbol (const char *name)
address@hidden {C Function} SCM scm_from_locale_symboln (const char *name, 
size_t len)
 Construct and return a Scheme symbol whose name is specified by
 @var{name}.  For @code{scm_from_locale_symbol}, @var{name} must be null
 terminated; for @code{scm_from_locale_symboln} the length of @var{name} is
@@ -5369,8 +5391,9 @@ specified explicitly by @var{len}.
 
 Note that these functions should @emph{not} be used when @var{name} is a
 C string constant, because there is no guarantee that the current locale
-will match that of the source code.  In such cases, use
address@hidden or @code{scm_from_utf8_symbol}.
+will match that of the execution character set, used for string and
+character constants.  Most modern C compilers use UTF-8 by default, so
+in such cases we recommend @code{scm_from_utf8_symbol}.
 @end deftypefn
 
 @deftypefn  {C Function} SCM scm_take_locale_symbol (char *str)
@@ -5770,6 +5793,8 @@ For further details on @code{let-keywords}, 
@code{define*} and other
 facilities provided by the @code{(ice-9 optargs)} module, see
 @ref{Optional Arguments}.
 
+To handle keyword arguments from procedures implemented in C,
+use @code{scm_c_bind_keyword_arguments} (@pxref{Keyword Procedures}).
 
 @node Keyword Read Syntax
 @subsubsection Keyword Read Syntax
@@ -5861,8 +5886,9 @@ Equivalent to @code{scm_symbol_to_keyword 
(scm_from_locale_symbol
 
 Note that these functions should @emph{not} be used when @var{name} is a
 C string constant, because there is no guarantee that the current locale
-will match that of the source code.  In such cases, use
address@hidden or @code{scm_from_utf8_keyword}.
+will match that of the execution character set, used for string and
+character constants.  Most modern C compilers use UTF-8 by default, so
+in such cases we recommend @code{scm_from_utf8_keyword}.
 @end deftypefn
 
 @deftypefn {C Function} SCM scm_from_latin1_keyword (const char *name)
@@ -5872,6 +5898,70 @@ Equivalent to @code{scm_symbol_to_keyword 
(scm_from_latin1_symbol
 (@var{name}))}, respectively.
 @end deftypefn
 
address@hidden {C Function} void scm_c_bind_keyword_arguments (const char 
*subr, @
+                             SCM rest, scm_t_keyword_arguments_flags flags, @
+                             SCM keyword1, SCM *argp1, @
+                             @dots{}, @
+                             SCM keywordN, SCM *argpN, @
+                             @nicode{SCM_UNDEFINED})
+
+Extract the specified keyword arguments from @var{rest}, which is not
+modified.  If the keyword argument @var{keyword1} is present in
address@hidden with an associated value, that value is stored in the
+variable pointed to by @var{argp1}, otherwise the variable is left
+unchanged.  Similarly for the other keywords and argument pointers up to
address@hidden and @var{argpN}.  The argument list to
address@hidden must be terminated by
address@hidden
+
+Note that since the variables pointed to by @var{argp1} through
address@hidden are left unchanged if the associated keyword argument is not
+present, they should be initialized to their default values before
+calling @code{scm_c_bind_keyword_arguments}.  Alternatively, you can
+initialize them to @code{SCM_UNDEFINED} before the call, and then use
address@hidden after the call to see which ones were provided.
+
+If an unrecognized keyword argument is present in @var{rest} and
address@hidden does not contain @code{SCM_ALLOW_OTHER_KEYS}, or if
+non-keyword arguments are present and @var{flags} does not contain
address@hidden, an exception is raised.
address@hidden should be the name of the procedure receiving the keyword
+arguments, for purposes of error reporting.
+
+For example:
+
address@hidden
+SCM k_delimiter;
+SCM k_grammar;
+SCM sym_infix;
+
+SCM my_string_join (SCM strings, SCM rest)
address@hidden
+  SCM delimiter = SCM_UNDEFINED;
+  SCM grammar   = sym_infix;
+
+  scm_c_bind_keyword_arguments ("my-string-join", rest, 0,
+                                k_delimiter, &delimiter,
+                                k_grammar, &grammar,
+                                SCM_UNDEFINED);
+
+  if (SCM_UNBNDP (delimiter))
+    delimiter = scm_from_utf8_string (" ");
+
+  return scm_string_join (strings, delimiter, grammar);
address@hidden
+
+void my_init ()
address@hidden
+  k_delimiter = scm_from_utf8_keyword ("delimiter");
+  k_grammar   = scm_from_utf8_keyword ("grammar");
+  sym_infix   = scm_from_utf8_symbol  ("infix");
+  scm_c_define_gsubr ("my-string-join", 1, 0, 1, my_string_join);
address@hidden
address@hidden example
address@hidden deftypefn
+
+
 @node Other Types
 @subsection ``Functionality-Centric'' Data Types
 
diff --git a/doc/ref/api-debug.texi b/doc/ref/api-debug.texi
index 2a86c1e..7f936fe 100644
--- a/doc/ref/api-debug.texi
+++ b/doc/ref/api-debug.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Guile Reference Manual.
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2007, 
2010, 2011, 2012
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2007, 
2010, 2011, 2012, 2013
 @c   Free Software Foundation, Inc.
 @c See the file guile.texi for copying conditions.
 
@@ -1176,7 +1176,9 @@ calls to @var{proc}.
 In addition, Guile defines a procedure to call a thunk, tracing all
 procedure calls and returns within the thunk.
 
address@hidden {Scheme Procedure} call-with-trace thunk  #:key (calls? #t) 
(instructions? #f) (width 80) (vm (the-vm))
address@hidden {Scheme Procedure} call-with-trace thunk [#:calls?=#t] @
+                          [#:instructions?=#f] @
+                          [#:width=80] [#:vm=(the-vm)]
 Call @var{thunk}, tracing all execution within its dynamic extent.
 
 If @var{calls?} is true, Guile will print a brief report at each
diff --git a/doc/ref/api-evaluation.texi b/doc/ref/api-evaluation.texi
index 0ffb501..63b1d60 100644
--- a/doc/ref/api-evaluation.texi
+++ b/doc/ref/api-evaluation.texi
@@ -22,6 +22,7 @@ loading, evaluating, and compiling Scheme code at run time.
 * Delayed Evaluation::          Postponing evaluation until it is needed.
 * Local Evaluation::            Evaluation in a local lexical environment.
 * Local Inclusion::             Compile-time inclusion of one file in another.
+* REPL Servers::                Serving a REPL over a socket.
 @end menu
 
 
@@ -488,7 +489,10 @@ procedure in the default environment, but you really want 
the one from
 (use-modules (ice-9 eval-string))
 @end example
 
address@hidden {Scheme Procedure} eval-string string [module=#f] [file=#f] 
[line=#f] [column=#f] [lang=(current-language)] [compile?=#f]
address@hidden {Scheme Procedure} eval-string string [#:module=#f] [#:file=#f] @
+                          [#:line=#f] [#:column=#f] @
+                          [#:lang=(current-language)] @
+                          [#:compile?=#f]
 Parse @var{string} according to the current language, normally Scheme.
 Evaluate or compile the expressions it contains, in order, returning the
 last expression.
@@ -691,7 +695,9 @@ coding declaration as recognized by @code{file-encoding}
 The compiler can also be invoked directly by Scheme code using the procedures
 below:
 
address@hidden {Scheme Procedure} compile exp [env=#f] 
[from=(current-language)] [to=value] [opts=()]
address@hidden {Scheme Procedure} compile exp [#:env=#f] @
+                          [#:from=(current-language)] @
+                          [#:to=value] [#:opts=()]
 Compile the expression @var{exp} in the environment @var{env}. If
 @var{exp} is a procedure, the result will be a compiled procedure;
 otherwise @code{compile} is mostly equivalent to @code{eval}.
@@ -700,10 +706,11 @@ For a discussion of languages and compiler options, 
@xref{Compiling to
 the Virtual Machine}.
 @end deffn
 
address@hidden {Scheme Procedure} compile-file file [output-file=#f] @
-  [from=(current-language)] [to='objcode] @
-  [env=(default-environment from)] [opts='()] @
-  [canonicalization 'relative]
address@hidden {Scheme Procedure} compile-file file [#:output-file=#f] @
+                          [#:from=(current-language)] [#:to='objcode] @
+                          [#:env=(default-environment from)] @
+                          [#:opts='()] @
+                          [#:canonicalization='relative]
 Compile the file named @var{file}.
 
 Output will be written to a @var{output-file}.   If you do not supply an
@@ -984,17 +991,19 @@ three arguments.
 @cindex source file encoding
 @cindex primitive-load
 @cindex load
-Scheme source code files are usually encoded in ASCII, but, the
-built-in reader can interpret other character encodings.  The
-procedure @code{primitive-load}, and by extension the functions that
-call it, such as @code{load}, first scan the top 500 characters of the
-file for a coding declaration.
+Scheme source code files are usually encoded in ASCII or UTF-8, but the
+built-in reader can interpret other character encodings as well.  When
+Guile loads Scheme source code, it uses the @code{file-encoding}
+procedure (described below) to try to guess the encoding of the file.
+In the absence of any hints, UTF-8 is assumed.  One way to provide a
+hint about the encoding of a source file is to place a coding
+declaration in the top 500 characters of the file.
 
 A coding declaration has the form @code{coding: XXXXXX}, where
 @code{XXXXXX} is the name of a character encoding in which the source
 code file has been encoded.  The coding declaration must appear in a
-scheme comment.  It can either be a semicolon-initiated comment or a block
address@hidden comment.
+scheme comment.  It can either be a semicolon-initiated comment, or the
+first block @code{#!} comment in the file.
 
 The name of the character encoding in the coding declaration is
 typically lower case and containing only letters, numbers, and hyphens,
@@ -1043,15 +1052,21 @@ the port's character encoding should be set to the 
encoding returned
 by @code{file-encoding}, if any, again by using
 @code{set-port-encoding!}.  Then the code can be read as normal.
 
+Alternatively, one can use the @code{#:guess-encoding} keyword argument
+of @code{open-file} and related procedures.  @xref{File Ports}.
+
 @deffn {Scheme Procedure} file-encoding port
 @deffnx {C Function} scm_file_encoding (port)
-Scan the port for an Emacs-like character coding declaration near the
-top of the contents of a port with random-accessible contents
-(@pxref{Recognize Coding, how Emacs recognizes file encoding,, emacs,
-The GNU Emacs Reference Manual}).  The coding declaration is of the form
address@hidden: XXXXX} and must appear in a Scheme comment.  Return a
-string containing the character encoding of the file if a declaration
-was found, or @code{#f} otherwise.  The port is rewound.
+Attempt to scan the first few hundred bytes from the @var{port} for
+hints about its character encoding.  Return a string containing the
+encoding name or @code{#f} if the encoding cannot be determined.  The
+port is rewound.
+
+Currently, the only supported method is to look for an Emacs-like
+character coding declaration (@pxref{Recognize Coding, how Emacs
+recognizes file encoding,, emacs, The GNU Emacs Reference Manual}).  The
+coding declaration is of the form @code{coding: XXXXX} and must appear
+in a Scheme comment.  Additional heuristics may be added in the future.
 @end deffn
 
 
@@ -1061,7 +1076,8 @@ was found, or @code{#f} otherwise.  The port is rewound.
 @cindex promises
 
 Promises are a convenient way to defer a calculation until its result
-is actually needed, and to run such a calculation only once.
+is actually needed, and to run such a calculation only once.  Also
address@hidden
 
 @deffn syntax delay expr
 @rnindex delay
@@ -1213,6 +1229,52 @@ the source files for a package (as you should!).  It 
makes it possible
 to evaluate an installed file from source, instead of relying on the
 @code{.go} file being up to date.
 
address@hidden REPL Servers
address@hidden REPL Servers
+
address@hidden REPL server
+
+The procedures in this section are provided by
address@hidden
+(use-modules (system repl server))
address@hidden lisp
+
+When an application is written in Guile, it is often convenient to
+allow the user to be able to interact with it by evaluating Scheme
+expressions in a REPL.
+
+The procedures of this module allow you to spawn a @dfn{REPL server},
+which permits interaction over a local or TCP connection.  Guile itself
+uses them internally to implement the @option{--listen} switch,
address@hidden Options}.
+
address@hidden {Scheme Procedure} make-tcp-server-socket [#:host=#f] @
+                          [#:addr] [#:port=37146]
+Return a stream socket bound to a given address @var{addr} and port
+number @var{port}. If the @var{host} is given, and @var{addr} is not,
+then the @var{host} string is converted to an address.  If neither is
+given, we use the loopback address.
address@hidden deffn
+
address@hidden {Scheme Procedure} make-unix-domain-server-socket 
[#:path="/tmp/guile-socket"]
+Return a UNIX domain socket, bound to a given @var{path}.
address@hidden deffn
+
address@hidden {Scheme Procedure} run-server [server-socket]
address@hidden {Scheme Procedure} spawn-server [server-socket]
+Create and run a REPL, making it available over the given
address@hidden  If @var{server-socket} is not provided, it
+defaults to the socket created by calling @code{make-tcp-server-socket}
+with no arguments.
+
address@hidden runs the server in the current thread, whereas
address@hidden runs the server in a new thread.
address@hidden deffn
+
address@hidden {Scheme Procedure} stop-server-and-clients!
+Closes the connection on all running server sockets.
address@hidden deffn
+
 @c Local Variables:
 @c TeX-master: "guile.texi"
 @c End:
diff --git a/doc/ref/api-foreign.texi b/doc/ref/api-foreign.texi
index f8ed4cc..e595668 100644
--- a/doc/ref/api-foreign.texi
+++ b/doc/ref/api-foreign.texi
@@ -489,6 +489,8 @@ platform-dependent size:
 @defvrx {Scheme Variable} long
 @defvrx {Scheme Variable} unsigned-long
 @defvrx {Scheme Variable} size_t
address@hidden {Scheme Variable} ssize_t
address@hidden {Scheme Variable} ptrdiff_t
 Values exported by the @code{(system foreign)} module, representing C
 numeric types. For example, @code{long} may be @code{equal?} to
 @code{int64} on a 64-bit platform.
@@ -801,8 +803,8 @@ int64_t a; uint8_t b; @}}:
 @end example
 
 As yet, Guile only has convenience routines to support
-conventionally-packed structs. But given the @code{bytevector->foreign}
-and @code{foreign->bytevector} routines, one can create and parse
+conventionally-packed structs. But given the @code{bytevector->pointer}
+and @code{pointer->bytevector} routines, one can create and parse
 tightly packed structs and unions by hand. See the code for
 @code{(system foreign)} for details.
 
diff --git a/doc/ref/api-io.texi b/doc/ref/api-io.texi
index 11ae580..4c42de8 100644
--- a/doc/ref/api-io.texi
+++ b/doc/ref/api-io.texi
@@ -1,7 +1,7 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Guile Reference Manual.
 @c Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2007, 2009,
address@hidden   2010, 2011  Free Software Foundation, Inc.
address@hidden   2010, 2011, 2013  Free Software Foundation, Inc.
 @c See the file guile.texi for copying conditions.
 
 @node Input and Output
@@ -19,6 +19,7 @@
 * Port Types::                  Types of port and how to make them.
 * R6RS I/O Ports::              The R6RS port API.
 * I/O Extensions::              Using and extending ports in C.
+* BOM Handling::                Handling of Unicode byte order marks.
 @end menu
 
 
@@ -842,7 +843,10 @@ Most systems have limits on how many files can be open, so 
it's
 strongly recommended that file ports be closed explicitly when no
 longer required (@pxref{Ports}).
 
address@hidden {Scheme Procedure} open-file filename mode
address@hidden {Scheme Procedure} open-file filename mode @
+                          [#:guess-encoding=#f] [#:encoding=#f]
address@hidden {C Function} scm_open_file_with_encoding @
+                     (filename, mode, guess_encoding, encoding)
 @deffnx {C Function} scm_open_file (filename, mode)
 Open the file whose name is @var{filename}, and return a port
 representing that file.  The attributes of the port are
@@ -884,8 +888,8 @@ Use binary mode, ensuring that each byte in the file will 
be read as one
 Scheme character.
 
 To provide this property, the file will be opened with the 8-bit
-character encoding "ISO-8859-1", ignoring any coding declaration or port
-encoding.  @xref{Ports}, for more information on port encodings.
+character encoding "ISO-8859-1", ignoring the default port encoding.
address@hidden, for more information on port encodings.
 
 Note that while it is possible to read and write binary data as
 characters or strings, it is usually better to treat bytes as octets,
@@ -899,15 +903,33 @@ to the underlying @code{open} call.  Still, the flag is 
generally useful
 because of its port encoding ramifications.
 @end table
 
-If a file cannot be opened with the access
-requested, @code{open-file} throws an exception.
+Unless binary mode is requested, the character encoding of the new port
+is determined as follows: First, if @var{guess-encoding} is true, the
address@hidden procedure is used to guess the encoding of the file
+(@pxref{Character Encoding of Source Files}).  If @var{guess-encoding}
+is false or if @code{file-encoding} fails, @var{encoding} is used unless
+it is also false.  As a last resort, the default port encoding is used.
address@hidden, for more information on port encodings.  It is an error to
+pass a non-false @var{guess-encoding} or @var{encoding} if binary mode
+is requested.
+
+If a file cannot be opened with the access requested, @code{open-file}
+throws an exception.
+
+When the file is opened, its encoding is set to the current
address@hidden, unless the @code{b} flag was supplied.
+Sometimes it is desirable to honor Emacs-style coding declarations in
address@hidden 2.0.0 to 2.0.7 would do this by default.  This
+behavior was deemed inappropriate and disabled starting from Guile
+2.0.8.}.  When that is the case, the @code{file-encoding} procedure can
+be used as follows (@pxref{Character Encoding of Source Files,
address@hidden):
 
-When the file is opened, this procedure will scan for a coding
-declaration (@pxref{Character Encoding of Source Files}). If a coding
-declaration is found, it will be used to interpret the file.  Otherwise,
-the port's encoding will be used.  To suppress this behavior, open the
-file in binary mode and then set the port encoding explicitly using
address@hidden
address@hidden
+(let* ((port     (open-input-file file))
+       (encoding (file-encoding port)))
+  (set-port-encoding! port (or encoding (port-encoding port))))
address@hidden example
 
 In theory we could create read/write ports which were buffered
 in one direction only.  However this isn't included in the
@@ -915,23 +937,40 @@ current interfaces.
 @end deffn
 
 @rnindex open-input-file
address@hidden {Scheme Procedure} open-input-file filename
-Open @var{filename} for input.  Equivalent to
address@hidden {Scheme Procedure} open-input-file filename @
+       [#:guess-encoding=#f] [#:encoding=#f] [#:binary=#f]
+
+Open @var{filename} for input.  If @var{binary} is true, open the port
+in binary mode, otherwise use text mode.  @var{encoding} and
address@hidden determine the character encoding as described above
+for @code{open-file}.  Equivalent to
 @lisp
-(open-file @var{filename} "r")
+(open-file @var{filename}
+           (if @var{binary} "rb" "r")
+           #:guess-encoding @var{guess-encoding}
+           #:encoding @var{encoding})
 @end lisp
 @end deffn
 
 @rnindex open-output-file
address@hidden {Scheme Procedure} open-output-file filename
-Open @var{filename} for output.  Equivalent to
address@hidden {Scheme Procedure} open-output-file filename @
+       [#:encoding=#f] [#:binary=#f]
+
+Open @var{filename} for output.  If @var{binary} is true, open the port
+in binary mode, otherwise use text mode.  @var{encoding} specifies the
+character encoding as described above for @code{open-file}.  Equivalent
+to
 @lisp
-(open-file @var{filename} "w")
+(open-file @var{filename}
+           (if @var{binary} "wb" "w")
+           #:encoding @var{encoding})
 @end lisp
 @end deffn
 
address@hidden {Scheme Procedure} call-with-input-file filename proc
address@hidden {Scheme Procedure} call-with-output-file filename proc
address@hidden {Scheme Procedure} call-with-input-file filename proc @
+        [#:guess-encoding=#f] [#:encoding=#f] [#:binary=#f]
address@hidden {Scheme Procedure} call-with-output-file filename proc @
+        [#:encoding=#f] [#:binary=#f]
 @rnindex call-with-input-file
 @rnindex call-with-output-file
 Open @var{filename} for input or output, and call @code{(@var{proc}
@@ -946,9 +985,12 @@ closed automatically, though it will be garbage collected 
in the usual
 way if not otherwise referenced.
 @end deffn
 
address@hidden {Scheme Procedure} with-input-from-file filename thunk
address@hidden {Scheme Procedure} with-output-to-file filename thunk
address@hidden {Scheme Procedure} with-error-to-file filename thunk
address@hidden {Scheme Procedure} with-input-from-file filename thunk @
+        [#:guess-encoding=#f] [#:encoding=#f] [#:binary=#f]
address@hidden {Scheme Procedure} with-output-to-file filename thunk @
+        [#:encoding=#f] [#:binary=#f]
address@hidden {Scheme Procedure} with-error-to-file filename thunk @
+        [#:encoding=#f] [#:binary=#f]
 @rnindex with-input-from-file
 @rnindex with-output-to-file
 Open @var{filename} and call @code{(@var{thunk})} with the new port
@@ -1214,9 +1256,10 @@ possible.
 * R6RS Textual Output::         Textual output.
 @end menu
 
-A subset of the @code{(rnrs io ports)} module is provided by the
address@hidden(ice-9 binary-ports)} module.  It contains binary input/output
-procedures and does not rely on R6RS support.
+A subset of the @code{(rnrs io ports)} module, plus one non-standard
+procedure @code{unget-bytevector} (@pxref{R6RS Binary Input}), is
+provided by the @code{(ice-9 binary-ports)} module.  It contains binary
+input/output procedures and does not rely on R6RS support.
 
 @node R6RS File Names
 @subsubsection File Names
@@ -1833,9 +1876,10 @@ actually read or the end-of-file object.
 
 @deffn {Scheme Procedure} get-bytevector-some port
 @deffnx {C Function} scm_get_bytevector_some (port)
-Read from @var{port}, blocking as necessary, until data are available or
-and end-of-file is reached.  Return either a new bytevector containing
-the data read or the end-of-file object.
+Read from @var{port}, blocking as necessary, until bytes are available
+or an end-of-file is reached.  Return either the end-of-file object or a
+new bytevector containing some of the available bytes (at least one),
+and update the port position to point just past these bytes.
 @end deffn
 
 @deffn {Scheme Procedure} get-bytevector-all port
@@ -1845,6 +1889,18 @@ reached.  Return either a new bytevector containing the 
data read or the
 end-of-file object (if no data were available).
 @end deffn
 
+The @code{(ice-9 binary-ports)} module provides the following procedure
+as an extension to @code{(rnrs io ports)}:
+
address@hidden {Scheme Procedure} unget-bytevector port bv [start [count]]
address@hidden {C Function} scm_unget_bytevector (port, bv, start, count)
+Place the contents of @var{bv} in @var{port}, optionally starting at
+index @var{start} and limiting to @var{count} octets, so that its bytes
+will be read from left-to-right as the next bytes from @var{port} during
+subsequent read operations.  If called multiple times, the unread bytes
+will be read again in last-in first-out order.
address@hidden deffn
+
 @node R6RS Textual Input
 @subsubsection Textual Input
 
@@ -2372,6 +2428,84 @@ Set using
 
 @end table
 
address@hidden BOM Handling
address@hidden Handling of Unicode byte order marks.
address@hidden BOM
address@hidden byte order mark
+
+This section documents the finer points of Guile's handling of Unicode
+byte order marks (BOMs).  A byte order mark (U+FEFF) is typically found
+at the start of a UTF-16 or UTF-32 stream, to allow readers to reliably
+determine the byte order.  Occasionally, a BOM is found at the start of
+a UTF-8 stream, but this is much less common and not generally
+recommended.
+
+Guile attempts to handle BOMs automatically, and in accordance with the
+recommendations of the Unicode Standard, when the port encoding is set
+to @code{UTF-8}, @code{UTF-16}, or @code{UTF-32}.  In brief, Guile
+automatically writes a BOM at the start of a UTF-16 or UTF-32 stream,
+and automatically consumes one from the start of a UTF-8, UTF-16, or
+UTF-32 stream.
+
+As specified in the Unicode Standard, a BOM is only handled specially at
+the start of a stream, and only if the port encoding is set to
address@hidden, @code{UTF-16} or @code{UTF-32}.  If the port encoding is
+set to @code{UTF-16BE}, @code{UTF-16LE}, @code{UTF-32BE}, or
address@hidden, then BOMs are @emph{not} handled specially, and none of
+the special handling described in this section applies.
+
address@hidden @bullet
address@hidden
+To ensure that Guile will properly detect the byte order of a UTF-16 or
+UTF-32 stream, you must perform a textual read before any writes, seeks,
+or binary I/O.  Guile will not attempt to read a BOM unless a read is
+explicitly requested at the start of the stream.
+
address@hidden
+If a textual write is performed before the first read, then an arbitrary
+byte order will be chosen.  Currently, big endian is the default on all
+platforms, but that may change in the future.  If you wish to explicitly
+control the byte order of an output stream, set the port encoding to
address@hidden, @code{UTF-16LE}, @code{UTF-32BE}, or @code{UTF-32LE},
+and explicitly write a BOM (@code{#\xFEFF}) if desired.
+
address@hidden
+If @code{set-port-encoding!} is called in the middle of a stream, Guile
+treats this as a new logical ``start of stream'' for purposes of BOM
+handling, and will forget about any BOMs that had previously been seen.
+Therefore, it may choose a different byte order than had been used
+previously.  This is intended to support multiple logical text streams
+embedded within a larger binary stream.
+
address@hidden
+Binary I/O operations are not guaranteed to update Guile's notion of
+whether the port is at the ``start of the stream'', nor are they
+guaranteed to produce or consume BOMs.
+
address@hidden
+For ports that support seeking (e.g. normal files), the input and output
+streams are considered linked: if the user reads first, then a BOM will
+be consumed (if appropriate), but later writes will @emph{not} produce a
+BOM.  Similarly, if the user writes first, then later reads will
address@hidden consume a BOM.
+
address@hidden
+For ports that do not support seeking (e.g. pipes, sockets, and
+terminals), the input and output streams are considered
address@hidden for purposes of BOM handling: the first read will
+consume a BOM (if appropriate), and the first write will @emph{also}
+produce a BOM (if appropriate).  However, the input and output streams
+will always use the same byte order.
+
address@hidden
+Seeks to the beginning of a file will set the ``start of stream'' flags.
+Therefore, a subsequent textual read or write will consume or produce a
+BOM.  However, unlike @code{set-port-encoding!}, if a byte order had
+already been chosen for the port, it will remain in effect after a seek,
+and cannot be changed by the presence of a BOM.  Seeks anywhere other
+than the beginning of a file clear the ``start of stream'' flags.
address@hidden itemize
+
 @c Local Variables:
 @c TeX-master: "guile.texi"
 @c End:
diff --git a/doc/ref/api-macros.texi b/doc/ref/api-macros.texi
index 347d025..09ffee6 100644
--- a/doc/ref/api-macros.texi
+++ b/doc/ref/api-macros.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Guile Reference Manual.
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2009, 
2010, 2011, 2012
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2009, 
2010, 2011, 2012, 2013
 @c   Free Software Foundation, Inc.
 @c See the file guile.texi for copying conditions.
 
@@ -215,7 +215,7 @@ including ellipsizing and tail patterns.
     ((_ #((var val) ...) exp exp* ...)
      (let ((var val) ...) exp exp* ...))))
 (letv #((foo 'bar)) foo)
address@hidden foo
address@hidden bar
 @end example
 
 Literals are used to match specific datums in an expression, like the use of
@@ -520,7 +520,8 @@ is impossible with @code{syntax-rules}, given the datum 
matching forms. But with
 @code{syntax-case} it is easy:
 
 @deffn {Scheme Procedure} identifier? syntax-object
-Returns @code{#t} iff @var{syntax-object} is an identifier.
+Returns @code{#t} if @var{syntax-object} is an identifier, or @code{#f}
+otherwise.
 @end deffn
 
 @example
@@ -690,13 +691,13 @@ macros can use to compare, generate, and query objects of 
this data
 type.
 
 @deffn {Scheme Procedure} bound-identifier=? a b
-Return @code{#t} iff the syntax objects @var{a} and @var{b} refer to the
-same lexically-bound identifier.
+Return @code{#t} if the syntax objects @var{a} and @var{b} refer to the
+same lexically-bound identifier, or @code{#f} otherwise.
 @end deffn
 
 @deffn {Scheme Procedure} free-identifier=? a b
-Return @code{#t} iff the syntax objects @var{a} and @var{b} refer to the
-same free identifier.
+Return @code{#t} if the syntax objects @var{a} and @var{b} refer to the
+same free identifier, or @code{#f} otherwise.
 @end deffn
 
 @deffn {Scheme Procedure} generate-temporaries ls
@@ -725,7 +726,7 @@ Return the name of the module whose source contains the 
identifier
 @var{id}.
 @end deffn
 
address@hidden {Scheme Procedure} syntax-local-binding id
address@hidden {Scheme Procedure} syntax-local-binding id 
[#:resolve-syntax-parameters?=#t]
 Resolve the identifer @var{id}, a syntax object, within the current
 lexical environment, and return two values, the binding type and a
 binding value.  The binding type is a symbol, which may be one of the
@@ -738,6 +739,12 @@ of @code{eq?}) identifying this binding.
 @item macro
 A syntax transformer, either local or global.  The value is the
 transformer procedure.
address@hidden syntax-parameter
+A syntax parameter (@pxref{Syntax Parameters}).  By default,
address@hidden will resolve syntax parameters, so that this
+value will not be returned.  Pass @code{#:resolve-syntax-parameters? #f}
+to indicate that you are interested in syntax parameters.  The value is
+the default transformer procedure, as in @code{macro}.
 @item pattern-variable
 A pattern variable, bound via syntax-case.  The value is an opaque
 object, internal to the expander.
@@ -935,7 +942,7 @@ left-hand side of a @code{set!} expression, as in the 
following:
 (set! foo @var{val})
 ;; expands via
 (foo-transformer #'(set! foo @var{val}))
-;; iff foo-transformer is a "variable transformer"
+;; if foo-transformer is a "variable transformer"
 @end example
 
 As the example notes, the transformer procedure must be explicitly
@@ -1125,7 +1132,8 @@ for syntax-case.
 
 @deffn {Scheme Procedure} macro? obj
 @deffnx {C Function} scm_macro_p (obj)
-Return @code{#t} iff @var{obj} is a syntax transformer.
+Return @code{#t} if @var{obj} is a syntax transformer, or @code{#f}
+otherwise.
 
 Note that it's a bit difficult to actually get a macro as a first-class object;
 simply naming it (like @code{case}) will produce a syntax error. But it is
diff --git a/doc/ref/api-modules.texi b/doc/ref/api-modules.texi
index 17ab462..286a37d 100644
--- a/doc/ref/api-modules.texi
+++ b/doc/ref/api-modules.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Guile Reference Manual.
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2007, 
2008, 2009, 2010, 2011, 2012
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2007, 
2008, 2009, 2010, 2011, 2012, 2013
 @c   Free Software Foundation, Inc.
 @c See the file guile.texi for copying conditions.
 
@@ -50,7 +50,6 @@ be used for interacting with the module system.
 * Variables::                   First-class variables.
 * Module System Reflection::    First-class modules.
 * Accessing Modules from C::    How to work with modules with C code.
-* Included Guile Modules::      Which modules come with Guile?
 * provide and require::         The SLIB feature mechanism.
 * Environments::                R5RS top-level environments.
 @end menu
@@ -111,8 +110,7 @@ interface is the one accessed.  For example:
 
 Here, the interface specification is @code{(ice-9 popen)}, and the
 result is that the current module now has access to @code{open-pipe},
address@hidden, @code{open-input-pipe}, and so on (@pxref{Included
-Guile Modules}).
address@hidden, @code{open-input-pipe}, and so on (@pxref{Pipes}).
 
 Note in the previous example that if the current module had already
 defined @code{open-pipe}, that definition would be overwritten by the
@@ -759,8 +757,8 @@ Return a variable initialized to value @var{init}.
 
 @deffn {Scheme Procedure} variable-bound? var
 @deffnx {C Function} scm_variable_bound_p (var)
-Return @code{#t} iff @var{var} is bound to a value.
-Throws an error if @var{var} is not a variable object.
+Return @code{#t} if @var{var} is bound to a value, or @code{#f}
+otherwise.  Throws an error if @var{var} is not a variable object.
 @end deffn
 
 @deffn {Scheme Procedure} variable-ref var
@@ -784,8 +782,8 @@ Unset the value of the variable @var{var}, leaving 
@var{var} unbound.
 
 @deffn {Scheme Procedure} variable? obj
 @deffnx {C Function} scm_variable_p (obj)
-Return @code{#t} iff @var{obj} is a variable object, else
-return @code{#f}.
+Return @code{#t} if @var{obj} is a variable object, else return
address@hidden
 @end deffn
 
 
@@ -827,7 +825,8 @@ the time @var{thunk}'s dynamic extent was last entered) is 
restored.  If
 saved, and the previously saved inner module is set current again.
 @end deffn
 
address@hidden {Scheme Procedure} resolve-module name [autoload=#t] 
[version=#f] [#:ensure=#t]
address@hidden {Scheme Procedure} resolve-module name [autoload=#t] 
[version=#f] @
+                          [#:ensure=#t]
 @deffnx {C Function} scm_resolve_module (name)
 Find the module named @var{name} and return it.  When it has not already
 been defined and @var{autoload} is true, try to auto-load it.  When it
@@ -837,7 +836,9 @@ that the resulting module is compatible with the given 
version reference
 (@pxref{R6RS Version References}).  The name is a list of symbols.
 @end deffn
 
address@hidden {Scheme Procedure} resolve-interface name [#:select=#f] 
[#:hide='()] [#:select=()] [#:prefix=#f] [#:renamer] [#:version=#f]
address@hidden {Scheme Procedure} resolve-interface name [#:select=#f] @
+                          [#:hide='()] [#:prefix=#f] @
+                          [#:renamer=#f] [#:version=#f]
 Find the module named @var{name} as with @code{resolve-module} and
 return its interface.  The interface of a module is also a module
 object, but it contains only the exported bindings.
@@ -942,14 +943,18 @@ the @var{name} is not bound in the module, signals an 
error.  Returns a
 variable, always.
 
 @example
-SCM my_eval_string (SCM str)
address@hidden
-  static SCM eval_string_var = SCM_BOOL_F;
+static SCM eval_string_var;
 
-  if (scm_is_false (eval_string_var))
-    eval_string_var =
-      scm_c_public_lookup ("ice-9 eval-string", "eval-string");
+/* NOTE: It is important that the call to 'my_init'
+   happens-before all calls to 'my_eval_string'. */
+void my_init (void)
address@hidden
+  eval_string_var = scm_c_public_lookup ("ice-9 eval-string",
+                                         "eval-string");
address@hidden
 
+SCM my_eval_string (SCM str)
address@hidden
   return scm_call_1 (scm_variable_ref (eval_string_var), str);
 @}
 @end example
@@ -1055,124 +1060,6 @@ of the current module.  The list of names is terminated 
by
 @end deftypefn
 
 
address@hidden Included Guile Modules
address@hidden Included Guile Modules
-
-Some modules are included in the Guile distribution; here are references
-to the entries in this manual which describe them in more detail:
-
address@hidden @strong
address@hidden boot-9
-boot-9 is Guile's initialization module, and it is always loaded when
-Guile starts up.
-
address@hidden (ice-9 expect)
-Actions based on matching input from a port (@pxref{Expect}).
-
address@hidden (ice-9 format)
-Formatted output in the style of Common Lisp (@pxref{Formatted
-Output}).
-
address@hidden (ice-9 ftw)
-File tree walker (@pxref{File Tree Walk}).
-
address@hidden (ice-9 getopt-long)
-Command line option processing (@pxref{getopt-long}).
-
address@hidden (ice-9 history)
-Refer to previous interactive expressions (@pxref{Value History}).
-
address@hidden (ice-9 popen)
-Pipes to and from child processes (@pxref{Pipes}).
-
address@hidden (ice-9 pretty-print)
-Nicely formatted output of Scheme expressions and objects
-(@pxref{Pretty Printing}).
-
address@hidden (ice-9 q)
-First-in first-out queues (@pxref{Queues}).
-
address@hidden (ice-9 rdelim)
-Line- and character-delimited input (@pxref{Line/Delimited}).
-
address@hidden (ice-9 readline)
address@hidden interactive command line editing (@pxref{Readline
-Support}).
-
address@hidden (ice-9 receive)
-Multiple-value handling with @code{receive} (@pxref{Multiple Values}).
-
address@hidden (ice-9 regex)
-Regular expression matching (@pxref{Regular Expressions}).
-
address@hidden (ice-9 rw)
-Block string input/output (@pxref{Block Reading and Writing}).
-
address@hidden (ice-9 streams)
-Sequence of values calculated on-demand (@pxref{Streams}).
-
address@hidden (ice-9 syncase)
-R5RS @code{syntax-rules} macro system (@pxref{Syntax Rules}).
-
address@hidden (ice-9 threads)
-Guile's support for multi threaded execution (@pxref{Scheduling}).
-
address@hidden (ice-9 documentation)
-Online documentation (REFFIXME).
-
address@hidden (srfi srfi-1)
-A library providing a lot of useful list and pair processing
-procedures (@pxref{SRFI-1}).
-
address@hidden (srfi srfi-2)
-Support for @code{and-let*} (@pxref{SRFI-2}).
-
address@hidden (srfi srfi-4)
-Support for homogeneous numeric vectors (@pxref{SRFI-4}).
-
address@hidden (srfi srfi-6)
-Support for some additional string port procedures (@pxref{SRFI-6}).
-
address@hidden (srfi srfi-8)
-Multiple-value handling with @code{receive} (@pxref{SRFI-8}).
-
address@hidden (srfi srfi-9)
-Record definition with @code{define-record-type} (@pxref{SRFI-9}).
-
address@hidden (srfi srfi-10)
-Read hash extension @code{#,()} (@pxref{SRFI-10}).
-
address@hidden (srfi srfi-11)
-Multiple-value handling with @code{let-values} and @code{let*-values}
-(@pxref{SRFI-11}).
-
address@hidden (srfi srfi-13)
-String library (@pxref{SRFI-13}).
-
address@hidden (srfi srfi-14)
-Character-set library (@pxref{SRFI-14}).
-
address@hidden (srfi srfi-16)
address@hidden procedures of variable arity (@pxref{SRFI-16}).
-
address@hidden (srfi srfi-17)
-Getter-with-setter support (@pxref{SRFI-17}).
-
address@hidden (srfi srfi-19)
-Time/Date library (@pxref{SRFI-19}).
-
address@hidden (srfi srfi-26)
-Convenient syntax for partial application (@pxref{SRFI-26})
-
address@hidden (srfi srfi-31)
address@hidden convenient recursive expressions (@pxref{SRFI-31})
-
address@hidden (ice-9 slib)
-This module contains hooks for using Aubrey Jaffer's portable Scheme
-library SLIB from Guile (@pxref{SLIB}).
address@hidden table
-
-
 @node provide and require
 @subsection provide and require
 
diff --git a/doc/ref/api-options.texi b/doc/ref/api-options.texi
index 1734318..8fa4f98 100644
--- a/doc/ref/api-options.texi
+++ b/doc/ref/api-options.texi
@@ -1,6 +1,7 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Guile Reference Manual.
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 
2006, 2008, 2009, 2010, 2011, 2012
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 
2006,
address@hidden   2008, 2009, 2010, 2011, 2012, 2013
 @c   Free Software Foundation, Inc.
 @c See the file guile.texi for copying conditions.
 
@@ -96,6 +97,13 @@ your site should be installed.  On Unix-like systems, this 
is usually
 @file{/usr/local/share/guile/site} or @file{/usr/share/guile/site}.
 @end deffn
 
address@hidden {Scheme Procedure} %site-ccache-dir
address@hidden {C Function} scm_sys_site_ccache_dir ()
+Return the directory where users should install compiled @code{.go}
+files for use with this version of Guile.  Might look something like
address@hidden/usr/lib/guile/@value{EFFECTIVE-VERSION}/site-ccache}.
address@hidden deffn
+
 @defvar %guile-build-info
 Alist of information collected during the building of a particular
 Guile.  Entries can be grouped into one of several categories:
@@ -274,6 +282,11 @@ Databases}).
 Indicates support for POSIX functions: @code{pipe}, @code{getgroups},
 @code{kill}, @code{execl} and so on (@pxref{POSIX}).
 
address@hidden fork
+Indicates support for the POSIX @code{fork} function (@pxref{Processes,
address@hidden).  This is a prerequisite for the @code{(ice-9
+popen)} module (@pxref{Pipes}).
+
 @item random
 Indicates availability of random number generation functions:
 @code{random}, @code{copy-random-state}, @code{random-uniform} and so on
diff --git a/doc/ref/api-procedures.texi b/doc/ref/api-procedures.texi
index bef3386..e11479d 100644
--- a/doc/ref/api-procedures.texi
+++ b/doc/ref/api-procedures.texi
@@ -157,7 +157,8 @@ appropriate module first, though:
 
 @deffn {Scheme Procedure} program? obj
 @deffnx {C Function} scm_program_p (obj)
-Returns @code{#t} iff @var{obj} is a compiled procedure.
+Returns @code{#t} if @var{obj} is a compiled procedure, or @code{#f}
+otherwise.
 @end deffn
 
 @deffn {Scheme Procedure} program-objcode program
@@ -333,7 +334,11 @@ cheaply, without allocating a rest list.
 @code{lambda*} is like @code{lambda}, except with some extensions to
 allow optional and keyword arguments.
 
address@hidden {library syntax} lambda* (address@hidden @* [#:optional 
address@hidden @* [#:key  address@hidden [#:allow-other-keys]] @* [#:rest var | 
. var]) @* body
address@hidden {library syntax} lambda* (address@hidden @* @
+                        [#:optional address@hidden @* @
+                        [#:key  address@hidden [#:allow-other-keys]] @* @
+                        [#:rest var | . var]) @* @
+                        body1 body2 @dots{}
 @sp 1
 Create a procedure which takes optional and/or keyword arguments
 specified with @code{#:optional} and @code{#:key}.  For example,
@@ -570,7 +575,8 @@ with @code{lambda} (@pxref{Lambda}).
 @example
 @group
 <case-lambda>
-   --> (case-lambda <case-lambda-clause>)
+   --> (case-lambda <case-lambda-clause>*)
+   --> (case-lambda <docstring> <case-lambda-clause>*)
 <case-lambda-clause>
    --> (<formals> <definition-or-command>*)
 <formals>
@@ -585,6 +591,7 @@ Rest lists can be useful with @code{case-lambda}:
 @lisp
 (define plus
   (case-lambda
+    "Return the sum of all arguments."
     (() 0)
     ((a) a)
     ((a b) (+ a b))
@@ -712,6 +719,11 @@ compatible arity.
 Return X.
 @end deffn
 
address@hidden {Scheme Procedure} and=> value proc
+When @var{value} is @code{#f}, return @code{#f}.  Otherwise, return
address@hidden(@var{proc} @var{value})}.
address@hidden deffn
+
 @node Procedure Properties
 @subsection Procedure Properties and Meta-information
 
diff --git a/doc/ref/api-scheduling.texi b/doc/ref/api-scheduling.texi
index 749583a..b230821 100644
--- a/doc/ref/api-scheduling.texi
+++ b/doc/ref/api-scheduling.texi
@@ -247,7 +247,7 @@ Once @var{body} or @var{handler} returns, the return value 
is made the
 
 @deffn {Scheme Procedure} thread? obj
 @deffnx {C Function} scm_thread_p (obj)
-Return @code{#t} iff @var{obj} is a thread; otherwise, return
+Return @code{#t} ff @var{obj} is a thread; otherwise, return
 @code{#f}.
 @end deffn
 
@@ -267,7 +267,7 @@ specified; @code{#f} is returned otherwise).
 
 @deffn {Scheme Procedure} thread-exited? thread
 @deffnx {C Function} scm_thread_exited_p (thread)
-Return @code{#t} iff @var{thread} has exited.
+Return @code{#t} if @var{thread} has exited, or @code{#f} otherwise.
 @end deffn
 
 @c begin (texi-doc-string "guile" "yield")
@@ -376,7 +376,7 @@ The returned mutex will be recursive.
 
 @deffn {Scheme Procedure} mutex? obj
 @deffnx {C Function} scm_mutex_p (obj)
-Return @code{#t} iff @var{obj} is a mutex; otherwise, return
+Return @code{#t} if @var{obj} is a mutex; otherwise, return
 @code{#f}.
 @end deffn
 
@@ -481,7 +481,7 @@ Return a new condition variable.
 
 @deffn {Scheme Procedure} condition-variable? obj
 @deffnx {C Function} scm_condition_variable_p (obj)
-Return @code{#t} iff @var{obj} is a condition variable; otherwise,
+Return @code{#t} if @var{obj} is a condition variable; otherwise,
 return @code{#f}.
 @end deffn
 
@@ -702,7 +702,7 @@ implicitly bound to some definite value).
 
 @deffn {Scheme Procedure} fluid? obj
 @deffnx {C Function} scm_fluid_p (obj)
-Return @code{#t} iff @var{obj} is a fluid; otherwise, return
+Return @code{#t} if @var{obj} is a fluid; otherwise, return
 @code{#f}.
 @end deffn
 
@@ -726,7 +726,7 @@ Disassociate the given fluid from any value, making it 
unbound.
 
 @deffn {Scheme Procedure} fluid-bound? fluid
 @deffnx {C Function} scm_fluid_bound_p (fluid)
-Returns @code{#t} iff the given fluid is bound to a value, otherwise
+Returns @code{#t} if the given fluid is bound to a value, otherwise
 @code{#f}.
 @end deffn
 
@@ -1037,6 +1037,13 @@ future has completed.  This suspend/resume is achieved 
by capturing the
 calling future's continuation, and later reinstating it (@pxref{Prompts,
 delimited continuations}).
 
+Note that @code{par-map} above is not tail-recursive.  This could lead
+to stack overflows when @var{lst} is large compared to
address@hidden(current-processor-count)}.  To address that, @code{touch} uses
+the suspend mechanism described above to limit the number of nested
+futures executing on the same stack.  Thus, the above code should never
+run into stack overflows.
+
 @deffn {Scheme Syntax} future exp
 Return a future for expression @var{exp}.  This is equivalent to:
 
diff --git a/doc/ref/api-smobs.texi b/doc/ref/api-smobs.texi
index cb2034c..345bf7c 100644
--- a/doc/ref/api-smobs.texi
+++ b/doc/ref/api-smobs.texi
@@ -124,9 +124,9 @@ Else, signal an error.
 @end deftypefn
 
 @deftypefn {C Macro} int SCM_SMOB_PREDICATE (scm_t_bits tag, SCM exp)
-Return true iff @var{exp} is a smob instance of the type indicated by
address@hidden  The expression @var{exp} can be evaluated more than once,
-so it shouldn't contain any side effects.
+Return true if @var{exp} is a smob instance of the type indicated by
address@hidden, or false otherwise.  The expression @var{exp} can be
+evaluated more than once, so it shouldn't contain any side effects.
 @end deftypefn
 
 @deftypefn {C Function} SCM scm_new_smob (scm_t_bits tag, void *data)
diff --git a/doc/ref/api-undocumented.texi b/doc/ref/api-undocumented.texi
index 1ffb3a9..4e478f4 100644
--- a/doc/ref/api-undocumented.texi
+++ b/doc/ref/api-undocumented.texi
@@ -188,8 +188,8 @@ would modify regular hash tables. (@pxref{Hash Tables})
 @end deffn
 
 @deffn {Scheme Procedure} include-deprecated-features
-Return @code{#t} iff deprecated features should be included
-in public interfaces.
+Return @code{#t} if deprecated features should be included in public
+interfaces, or @code{#f} otherwise.
 @end deffn
 
 @deffn {Scheme Procedure} issue-deprecation-warning . msgs
@@ -202,7 +202,7 @@ they are printed in turn, each one followed by a newline.
 
 @deffn {Scheme Procedure} valid-object-procedure? proc
 @deffnx {C Function} scm_valid_object_procedure_p (proc)
-Return @code{#t} iff @var{proc} is a procedure that can be used with 
@code{set-object-procedure}.  It is always valid to use a closure constructed 
by @code{lambda}.
+Return @code{#t} ff @var{proc} is a procedure that can be used with 
@code{set-object-procedure}.  It is always valid to use a closure constructed 
by @code{lambda}.
 @end deffn
 
 @deffn {Scheme Procedure} %get-pre-modules-obarray
diff --git a/doc/ref/api-utility.texi b/doc/ref/api-utility.texi
index 17694ec..76c50b2 100644
--- a/doc/ref/api-utility.texi
+++ b/doc/ref/api-utility.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Guile Reference Manual.
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2011, 
2012
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2011, 
2012, 2013
 @c   Free Software Foundation, Inc.
 @c See the file guile.texi for copying conditions.
 
@@ -308,10 +308,10 @@ input.
 
 @deffn {Scheme Procedure} sorted? items less
 @deffnx {C Function} scm_sorted_p (items, less)
-Return @code{#t} iff @var{items} is a list or vector such that,
+Return @code{#t} if @var{items} is a list or vector such that,
 for each element @var{x} and the next element @var{y} of
 @var{items}, @code{(@var{less} @var{y} @var{x})} returns
address@hidden
address@hidden  Otherwise return @code{#f}.
 @end deffn
 
 @deffn {Scheme Procedure} sort items less
diff --git a/doc/ref/compiler.texi b/doc/ref/compiler.texi
index fcb4a0e..0615ef7 100644
--- a/doc/ref/compiler.texi
+++ b/doc/ref/compiler.texi
@@ -53,9 +53,11 @@ Languages are registered in the module, @code{(system base 
language)}:
 They are registered with the @code{define-language} form.
 
 @deffn {Scheme Syntax} define-language @
-name title reader printer @
-[parser=#f] [compilers='()] [decompilers='()] [evaluator=#f] @
-[joiner=#f] [make-default-environment=make-fresh-user-module]
+                       [#:name] [#:title] [#:reader] [#:printer] @
+                       [#:parser=#f] [#:compilers='()] @
+                       [#:decompilers='()] [#:evaluator=#f] @
+                       [#:joiner=#f] [#:for-humans?=#t] @
+                       [#:make-default-environment=make-fresh-user-module]
 Define a language.
 
 This syntax defines a @code{#<language>} object, bound to @var{name}
@@ -589,9 +591,9 @@ variables. @var{vars} is a list of @code{(@var{name} 
@var{type}
 program's metadata and do not form part of a program's code path.
 @end deftp
 @deftp {Scheme Variable} <glil-mv-bind> vars rest
-A multiple-value binding of the values on the stack to @var{vars}. Iff
address@hidden is true, the last element of @var{vars} will be treated as
-a rest argument.
+A multiple-value binding of the values on the stack to @var{vars}.  If
address@hidden is true, the last element of @var{vars} will be treated as a
+rest argument.
 
 In addition to pushing a binding annotation on the stack, like
 @code{<glil-bind>}, an expression is emitted at compilation time to
@@ -798,7 +800,7 @@ objcode)} module.
 
 @deffn {Scheme Procedure} objcode? obj
 @deffnx {C Function} scm_objcode_p (obj)
-Returns @code{#f} iff @var{obj} is object code, @code{#f} otherwise.
+Returns @code{#f} if @var{obj} is object code, @code{#f} otherwise.
 @end deffn
 
 @deffn {Scheme Procedure} bytecode->objcode bytecode [endianness]
diff --git a/doc/ref/guile-invoke.texi b/doc/ref/guile-invoke.texi
index 5a9a3f7..207c6f3 100644
--- a/doc/ref/guile-invoke.texi
+++ b/doc/ref/guile-invoke.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Guile Reference Manual.
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 
2010, 2011
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2005, 
2010, 2011, 2013
 @c   Free Software Foundation, Inc.
 @c See the file guile.texi for copying conditions.
 
@@ -71,6 +71,9 @@ before any directories in the @env{GUILE_LOAD_PATH} 
environment
 variable.  Paths added here are @emph{not} in effect during execution of
 the user's @file{.guile} file.
 
address@hidden -C @var{directory}
+Like @option{-L}, but adjusts the load path for @emph{compiled} files.
+
 @item -x @var{extension}
 Add @var{extension} to the front of Guile's load extension list
 (@pxref{Load Paths, @code{%load-extensions}}).  The specified extensions
@@ -205,6 +208,35 @@ Treat the auto-compilation cache as invalid, forcing 
recompilation.
 @item --no-auto-compile
 Disable automatic source file compilation.
 
address@hidden
+
address@hidden address@hidden
+For the remainder of the command line arguments, assume that files
+mentioned with @code{-l} and expressions passed with @code{-c} are
+written in @var{lang}.  @var{lang} must be the name of one of the
+languages supported by the compiler (@pxref{Compiler Tower}).  When run
+interactively, set the REPL's language to @var{lang} (@pxref{Using Guile
+Interactively}).
+
+The default language is @code{scheme}; other interesting values include
address@hidden (for Emacs Lisp), and @code{ecmascript}.
+
+The example below shows the evaluation of expressions in Scheme, Emacs
+Lisp, and ECMAScript:
+
address@hidden
+guile -c "(apply + '(1 2))"
+guile --language=elisp -c "(= (funcall (symbol-function '+) 1 2) 3)"
+guile --language=ecmascript -c '(function (x) @{ return x * x; @})(2);'
address@hidden example
+
+To load a file written in Scheme and one written in Emacs Lisp, and then
+start a Scheme REPL, type:
+
address@hidden
+guile -l foo.scm --language=elisp -l foo.el --language=scheme
address@hidden example
+
 @vnew{2.0}
 
 @item address@hidden, }--help
@@ -291,6 +323,32 @@ This variable names the file that holds the Guile REPL 
command history.
 You can specify a different history file by setting this environment
 variable.  By default, the history file is @file{$HOME/.guile_history}.
 
address@hidden GUILE_INSTALL_LOCALE
address@hidden GUILE_INSTALL_LOCALE
+This is a flag that can be used to tell Guile whether or not to install
+the current locale at startup, via a call to @code{(setlocale LC_ALL
+"")}.  @xref{Locales}, for more information on locales.
+
+You may explicitly indicate that you do not want to install
+the locale by setting @env{GUILE_INSTALL_LOCALE} to @code{0}, or
+explicitly enable it by setting the variable to @code{1}.
+
+Usually, installing the current locale is the right thing to do.  It
+allows Guile to correctly parse and print strings with non-ASCII
+characters.  Therefore, this option is on by default.
+
address@hidden GUILE_STACK_SIZE
address@hidden GUILE_STACK_SIZE
+Guile currently has a limited stack size for Scheme computations.
+Attempting to call too many nested functions will signal an error.  This
+is good to detect infinite recursion, but sometimes the limit is reached
+for normal computations.  This environment variable, if set to a
+positive integer, specifies the number of Scheme value slots to allocate
+for the stack.
+
+In the future we will implement stacks that can grow and shrink, but for
+now this hack will have to do.
+
 @item GUILE_LOAD_COMPILED_PATH
 @vindex GUILE_LOAD_COMPILED_PATH
 This variable may be used to augment the path that is searched for
diff --git a/doc/ref/guile.texi b/doc/ref/guile.texi
index 262cd64..c3170ce 100644
--- a/doc/ref/guile.texi
+++ b/doc/ref/guile.texi
@@ -374,7 +374,7 @@ available through both Scheme and C interfaces.
 * Curried Definitions::         Extended @code{define} syntax.
 * Statprof::                    An easy-to-use statistical profiler.
 * SXML::                        Parsing, transforming, and serializing XML.
-* Texinfo::                     Munging documents written in Texinfo.
+* Texinfo Processing::          Munging documents written in Texinfo.
 @end menu
 
 @include slib.texi
diff --git a/doc/ref/intro.texi b/doc/ref/intro.texi
index e94948f..28da4ac 100644
--- a/doc/ref/intro.texi
+++ b/doc/ref/intro.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Guile Reference Manual.
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2006, 
2010, 2011
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2006, 
2010, 2011, 2013
 @c   Free Software Foundation, Inc.
 @c See the file guile.texi for copying conditions.
 
@@ -288,21 +288,6 @@ classes, multiple inheritance and generic functions.
 @node Typographical Conventions
 @section Typographical Conventions
 
-We use some conventions in this manual.
-
address@hidden @bullet
-
address@hidden
-For some procedures, notably type predicates, we use ``iff'' to mean
-``if and only if''.  The construct is usually something like: `Return
address@hidden iff @var{condition}', where @var{val} is usually
address@hidden'' or address@hidden''.  This typically means that
address@hidden is returned if @var{condition} holds, and that @samp{#f} is
-returned otherwise.  To clarify: @var{val} will @strong{only} be
-returned when @var{condition} is true.
address@hidden iff
-
address@hidden
 In examples and procedure descriptions and all other places where the
 evaluation of Scheme expression is shown, we use some notation for
 denoting the output and evaluation results of expressions.
@@ -328,10 +313,6 @@ As you can see, this code prints @samp{1} (denoted by
 @address@hidden), and returns @code{hooray} (denoted by
 @address@hidden).
 
address@hidden Add other conventions here.
-
address@hidden itemize
-
 
 @c Local Variables:
 @c TeX-master: "guile.texi"
diff --git a/doc/ref/misc-modules.texi b/doc/ref/misc-modules.texi
index cf1e0e4..c1e65d7 100644
--- a/doc/ref/misc-modules.texi
+++ b/doc/ref/misc-modules.texi
@@ -1573,6 +1573,9 @@ modifies the queue @var{list} then it must either maintain
 @section Streams
 @cindex streams
 
+This section documents Guile's legacy stream module.  For a more
+complete and portable stream library, @pxref{SRFI-41}.
+
 A stream represents a sequence of values, each of which is calculated
 only when required.  This allows large or even infinite sequences to
 be represented and manipulated with familiar operations like ``car'',
diff --git a/doc/ref/posix.texi b/doc/ref/posix.texi
index a019f4e..40c20e7 100644
--- a/doc/ref/posix.texi
+++ b/doc/ref/posix.texi
@@ -803,6 +803,36 @@ Copy the file specified by @var{oldfile} to @var{newfile}.
 The return value is unspecified.
 @end deffn
 
address@hidden {Scheme Procedure} sendfile out in count [offset]
address@hidden {C Function} scm_sendfile (out, in, count, offset)
+Send @var{count} bytes from @var{in} to @var{out}, both of which
+must be either open file ports or file descriptors.  When
address@hidden is omitted, start reading from @var{in}'s current
+position; otherwise, start reading at @var{offset}.  Return
+the number of bytes actually sent.
+
+When @var{in} is a port, it is often preferable to specify @var{offset},
+because @var{in}'s offset as a port may be different from the offset of
+its underlying file descriptor.
+
+On systems that support it, such as GNU/Linux, this procedure uses the
address@hidden libc function, which usually corresponds to a system
+call.  This is faster than doing a series of @code{read} and
address@hidden system calls.  A typical application is to send a file over
+a socket.
+
+In some cases, the @code{sendfile} libc function may return
address@hidden or @code{ENOSYS}.  In that case, Guile's @code{sendfile}
+procedure automatically falls back to doing a series of @code{read} and
address@hidden calls.
+
+In other cases, the libc function may send fewer bytes than
address@hidden instance because @var{out} is a slow or limited
+device, such as a pipe.  When that happens, Guile's @code{sendfile}
+automatically retries until exactly @var{count} bytes were sent or an
+error occurs.
address@hidden deffn
+
 @findex rename
 @deffn {Scheme Procedure} rename-file oldname newname
 @deffnx {C Function} scm_rename (oldname, newname)
@@ -986,6 +1016,43 @@ Return @code{#t} if the file named @var{filename} exists, 
@code{#f} if
 not.
 @end deffn
 
address@hidden file name separator
address@hidden absolute file name
+
+Many operating systems, such as GNU, use @code{/} (forward slash) to
+separate the components of a file name; any file name starting with
address@hidden/} is considered an @dfn{absolute file name}.  These conventions
+are specified by the POSIX Base Definitions, which refer to conforming
+file names as ``pathnames''.  Some operating systems use a different
+convention; in particular, Windows uses @code{\} (backslash) as the file
+name separator, and also has the notion of @dfn{volume names} like
address@hidden:\} for absolute file names.  The following procedures and
+variables provide support for portable file name manipulations.
+
address@hidden {Scheme Procedure} system-file-name-convention
+Return either @code{posix} or @code{windows}, depending on
+what kind of system this Guile is running on.
address@hidden deffn
+
address@hidden {Scheme Procedure} file-name-separator? c
+Return true if character @var{c} is a file name separator on the host
+platform.
address@hidden deffn
+
address@hidden {Scheme Procedure} absolute-file-name? file-name
+Return true if @var{file-name} denotes an absolute file name on the host
+platform.
address@hidden deffn
+
address@hidden {Scheme Variable} file-name-separator-string
+The preferred file name separator.
+
+Note that on MinGW builds for Windows, both @code{/} and @code{\} are
+valid separators.  Thus, programs should not assume that
address@hidden is the @emph{only} file name
+separator---e.g., when extracting the components of a file name.
address@hidden defvr
+
 
 @node User Information
 @subsection User Information
@@ -1718,6 +1785,18 @@ interpretation is not required.
 Example: (system* "echo" "foo" "bar")
 @end deffn
 
address@hidden {Scheme Procedure} quit [status]
address@hidden {Scheme Procedure} exit [status]
+Terminate the current process with proper unwinding of the Scheme stack.
+The exit status zero if @var{status} is not supplied.  If @var{status}
+is supplied, and it is an integer, that integer is used as the exit
+status.  If @var{status} is @code{#t} or @code{#f}, the exit status is 0
+or 1, respectively.
+
+The procedure @code{exit} is an alias of @code{quit}.  They have the
+same functionality.
address@hidden deffn
+
 @deffn {Scheme Procedure} primitive-exit [status]
 @deffnx {Scheme Procedure} primitive-_exit [status]
 @deffnx {C Function} scm_primitive_exit (status)
@@ -2154,7 +2233,8 @@ controlling terminal.  The return value is unspecified.
 
 The following procedures are similar to the @code{popen} and
 @code{pclose} system routines.  The code is in a separate ``popen''
-module:
address@hidden module is only available on systems where the
address@hidden feature is provided (@pxref{Common Feature Symbols}).}:
 
 @lisp
 (use-modules (ice-9 popen))
@@ -2528,8 +2608,11 @@ code should be prepared to handle it when it is defined.
 @var{hint_socktype} was not recognized.
 
 @item EAI_SYSTEM
-A system error occurred; the error code can be found in
address@hidden
+A system error occurred.  In C, the error code can be found in
address@hidden; this value is not accessible from Scheme, but in
+practice it provides little information about the actual error
+cause.
address@hidden See <http://bugs.gnu.org/13958>.
 @end table
 
 Users are encouraged to read the
@@ -3052,6 +3135,7 @@ Manual}, or @command{man 7 socket}.
 @defvarx SO_OOBINLINE
 @defvarx SO_NO_CHECK
 @defvarx SO_PRIORITY
address@hidden SO_REUSEPORT
 The @var{value} taken or returned is an integer.
 @end defvar
 
diff --git a/doc/ref/r6rs.texi b/doc/ref/r6rs.texi
index 2028ada..9c5984b 100644
--- a/doc/ref/r6rs.texi
+++ b/doc/ref/r6rs.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Guile Reference Manual.
address@hidden Copyright (C)  2010, 2011, 2012
address@hidden Copyright (C)  2010, 2011, 2012, 2013
 @c   Free Software Foundation, Inc.
 @c See the file guile.texi for copying conditions.
 
@@ -273,10 +273,8 @@ grouped below by the existing manual sections to which 
they correspond.
 @end deffn
 
 @deffn {Scheme Syntax} define-syntax keyword expression
address@hidden {Scheme Syntax} let-syntax ((keyword transformer) @dots{})
-                        exp1 exp2 @dots{}
address@hidden {Scheme Syntax} letrec-syntax ((keyword transformer) @dots{})
-                        exp1 exp2 @dots{}
address@hidden {Scheme Syntax} let-syntax ((keyword transformer) @dots{}) exp1 
exp2 @dots{}
address@hidden {Scheme Syntax} letrec-syntax ((keyword transformer) @dots{}) 
exp1 exp2 @dots{}
 @xref{Defining Macros}, for documentation.
 @end deffn
 
@@ -828,11 +826,11 @@ This form is identical to the one provided by Guile's 
core library.
 @node R6RS Records
 @subsubsection R6RS Records
 
-The manual sections below describe Guile's implementation of R6RS 
+The manual sections below describe Guile's implementation of R6RS
 records, which provide support for user-defined data types.  The R6RS
 records API provides a superset of the features provided by Guile's
 ``native'' records, as well as those of the SRFI-9 records API;
address@hidden, and @ref{SRFI-9}, for a description of those
address@hidden, and @ref{SRFI-9 Records}, for a description of those
 interfaces.
 
 As with SRFI-9 and Guile's native records, R6RS records are constructed
@@ -1523,9 +1521,9 @@ This procedure is identical to the one provided by 
Guile's core library.
 @xref{Runtime Environment}, for documentation.
 @end deffn
 
address@hidden {Scheme Procedure} exit
address@hidden {Scheme Procedure} exit obj
-This procedure is identical to the one provided by Guile's core library.
address@hidden {Scheme Procedure} exit [status]
+This procedure is identical to the one provided by Guile's core
+library. @xref{Processes}, for documentation.
 @end deffn
 
 @node rnrs arithmetic fixnums
diff --git a/doc/ref/scheme-using.texi b/doc/ref/scheme-using.texi
index e0f91af..4422c18 100644
--- a/doc/ref/scheme-using.texi
+++ b/doc/ref/scheme-using.texi
@@ -125,7 +125,7 @@ The programmatic interface to value history is in a module:
 @end lisp
 
 @deffn {Scheme Procedure} value-history-enabled?
-Return true iff value history is enabled.
+Return true if value history is enabled, or false otherwise.
 @end deffn
 
 @deffn {Scheme Procedure} enable-value-history!
@@ -430,8 +430,11 @@ Garbage collection.
 Display statistics.
 @end deffn
 
address@hidden {REPL Command} option [key value]
-List/show/set options.
address@hidden {REPL Command} option [name] [exp]
+With no arguments, lists all options.  With one argument, shows the
+current value of the @var{name} option.  With two arguments, sets the
address@hidden option to the result of evaluating the Scheme expression
address@hidden
 @end deffn
 
 @deffn {REPL Command} quit
@@ -749,6 +752,7 @@ list}, or simply @code{guild}.
 @cindex site path
 @cindex load path
 @findex %site-dir
address@hidden %site-ccache-dir
 
 At some point, you will probably want to share your code with other
 people.  To do so effectively, it is important to follow a set of common
@@ -780,11 +784,11 @@ find them.
 As with Scheme files, Guile searches a path to find compiled @code{.go}
 files, the @code{%load-compiled-path}.  By default, this path has two
 entries: a path for Guile's files, and a path for site packages.  You
-should install your @code{.go} files into the latter.  Currently there
-is no procedure to get at this path, which is probably a bug.  As in the
-previous example, if Guile @value{EFFECTIVE-VERSION} is installed on
-your system in @code{/usr/}, then the place to put compiled files for
-site packages will be
+should install your @code{.go} files into the latter directory, whose
+value is returned by invoking the @code{%site-ccache-dir} procedure.  As
+in the previous example, if Guile @value{EFFECTIVE-VERSION} is installed
+on your system in @code{/usr/}, then @code{(%site-ccache-dir)} site
+packages will be
 @code{/usr/lib/guile/@value{EFFECTIVE-VERSION}/site-ccache}.
 
 Note that a @code{.go} file will only be loaded in preference to a
diff --git a/doc/ref/srfi-modules.texi b/doc/ref/srfi-modules.texi
index f92ddaf..f0158d5 100644
--- a/doc/ref/srfi-modules.texi
+++ b/doc/ref/srfi-modules.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Guile Reference Manual.
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2006, 
2007, 2008, 2009, 2010, 2011, 2012
address@hidden Copyright (C)  1996, 1997, 2000, 2001, 2002, 2003, 2004, 2006, 
2007, 2008, 2009, 2010, 2011, 2012, 2013
 @c   Free Software Foundation, Inc.
 @c See the file guile.texi for copying conditions.
 
@@ -45,6 +45,7 @@ get the relevant SRFI documents from the SRFI home page
 * SRFI-37::                     args-fold program argument processor
 * SRFI-38::                     External Representation for Data With Shared 
Structure
 * SRFI-39::                     Parameter objects
+* SRFI-41::                     Streams.
 * SRFI-42::                     Eager comprehensions
 * SRFI-45::                     Primitives for expressing iterative lazy 
algorithms
 * SRFI-55::                     Requiring Features.
@@ -76,13 +77,13 @@ check for the Scheme implementation, that is, before she 
can know that
 it is safe to use @code{use-modules} to load SRFI support modules.  The
 second reason is that some features defined in SRFIs had been
 implemented in Guile before the developers started to add SRFI
-implementations as modules (for example SRFI-6 (@pxref{SRFI-6})).  In
+implementations as modules (for example SRFI-13 (@pxref{SRFI-13})).  In
 the future, it is possible that SRFIs in the core library might be
 factored out into separate modules, requiring explicit module loading
 when they are needed.  So you should be prepared to have to use
address@hidden someday in the future to access SRFI-6 bindings.  If
address@hidden someday in the future to access SRFI-13 bindings.  If
 you want, you can do that already.  We have included the module
address@hidden(srfi srfi-6)} in the distribution, which currently does nothing,
address@hidden(srfi srfi-13)} in the distribution, which currently does nothing,
 but ensures that you can write future-safe code.
 
 Generally, support for a specific SRFI is made available by using
@@ -145,9 +146,13 @@ guile-2  ;; starting from Guile 2.x
 r5rs
 srfi-0
 srfi-4
-srfi-6
 srfi-13
 srfi-14
+srfi-23
+srfi-39
+srfi-55
+srfi-61
+srfi-105
 @end example
 
 Other SRFI feature symbols are defined once their code has been loaded
@@ -1770,8 +1775,8 @@ Like @code{scm_vector_writable_elements} (@pxref{Vector 
Accessing from
 C}), but returns a pointer to the elements of a uniform numeric vector.
 @end deftypefn
 
-Unless you really need to the limited generality of these functions, it is best
-to use the type-specific functions, or the generalized vector accessors.
+Unless you really need to the limited generality of these functions, it
+is best to use the type-specific functions, or the array accessors.
 
 @node SRFI-4 and Bytevectors
 @subsubsection SRFI-4 - Relation to bytevectors
@@ -1846,11 +1851,19 @@ uniform numeric vector, it is returned unchanged.
 @cindex SRFI-6
 
 SRFI-6 defines the procedures @code{open-input-string},
address@hidden and @code{get-output-string}.  These
-procedures are included in the Guile core, so using this module does not
-make any difference at the moment.  But it is possible that support for
-SRFI-6 will be factored out of the core library in the future, so using
-this module does not hurt, after all.
address@hidden and @code{get-output-string}.
+
+Note that although versions of these procedures are included in the
+Guile core, the core versions are not fully conformant with SRFI-6:
+attempts to read or write characters that are not supported by the
+current @code{%default-port-encoding} will fail.
+
+We therefore recommend that you import this module, which supports all
+characters:
+
address@hidden
+(use-modules (srfi srfi-6))
address@hidden example
 
 @node SRFI-8
 @subsection SRFI-8 - receive
@@ -3429,9 +3442,10 @@ Note that all fields of @var{type} and its supertypes 
must be specified.
 @end deffn
 
 @deffn {Scheme Procedure} make-compound-condition condition1 condition2 @dots{}
-Return a new compound condition composed of @var{conditions}.  The
-returned condition has the type of each condition of @var{conditions}
-(per @code{condition-has-type?}).
+Return a new compound condition composed of @var{condition1}
address@hidden @enddots{}.  The returned condition has the type of
+each condition of condition1 condition2 @dots{} (per
address@hidden).
 @end deffn
 
 @deffn {Scheme Procedure} condition-has-type? c type
@@ -3775,6 +3789,712 @@ scope and the result from that @var{thunk} is the 
return from
 @code{with-parameters*}.
 @end defun
 
address@hidden SRFI-41
address@hidden SRFI-41 - Streams
address@hidden SRFI-41
+
+This subsection is based on the
address@hidden://srfi.schemers.org/srfi-41/srfi-41.html, specification of
+SRFI-41} by Philip L.@: Bewig.
+
address@hidden The copyright notice and license text of the SRFI-41 
specification is
address@hidden reproduced below:
+
address@hidden Copyright (C) Philip L. Bewig (2007). All Rights Reserved.
+
address@hidden Permission is hereby granted, free of charge, to any person 
obtaining a
address@hidden copy of this software and associated documentation files (the
address@hidden "Software"), to deal in the Software without restriction, 
including
address@hidden without limitation the rights to use, copy, modify, merge, 
publish,
address@hidden distribute, sublicense, and/or sell copies of the Software, and 
to
address@hidden permit persons to whom the Software is furnished to do so, 
subject to
address@hidden the following conditions:
+
address@hidden The above copyright notice and this permission notice shall be 
included
address@hidden in all copies or substantial portions of the Software.
+
address@hidden THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
EXPRESS
address@hidden OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
address@hidden MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
address@hidden NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
HOLDERS BE
address@hidden LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 
ACTION
address@hidden OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
CONNECTION
address@hidden WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
address@hidden
+This SRFI implements streams, sometimes called lazy lists, a sequential
+data structure containing elements computed only on demand.  A stream is
+either null or is a pair with a stream in its cdr.  Since elements of a
+stream are computed only when accessed, streams can be infinite.  Once
+computed, the value of a stream element is cached in case it is needed
+again.  SRFI-41 can be made available with:
+
address@hidden
+(use-modules (srfi srfi-41))
address@hidden example
+
address@hidden
+* SRFI-41 Stream Fundamentals::
+* SRFI-41 Stream Primitives::
+* SRFI-41 Stream Library::
address@hidden menu
+
address@hidden SRFI-41 Stream Fundamentals
address@hidden SRFI-41 Stream Fundamentals
+
+SRFI-41 Streams are based on two mutually-recursive abstract data types:
+An object of the @code{stream} abstract data type is a promise that,
+when forced, is either @code{stream-null} or is an object of type
address@hidden  An object of the @code{stream-pair} abstract data
+type contains a @code{stream-car} and a @code{stream-cdr}, which must be
+a @code{stream}.  The essential feature of streams is the systematic
+suspensions of the recursive promises between the two data types.
+
+The object stored in the @code{stream-car} of a @code{stream-pair} is a
+promise that is forced the first time the @code{stream-car} is accessed;
+its value is cached in case it is needed again.  The object may have any
+type, and different stream elements may have different types.  If the
address@hidden is never accessed, the object stored there is never
+evaluated.  Likewise, the @code{stream-cdr} is a promise to return a
+stream, and is only forced on demand.
+
address@hidden SRFI-41 Stream Primitives
address@hidden SRFI-41 Stream Primitives
+
+This library provides eight operators: constructors for
address@hidden and @code{stream-pair}s, type predicates for streams
+and the two kinds of streams, accessors for both fields of a
address@hidden, and a lambda that creates procedures that return
+streams.
+
address@hidden {Scheme Variable} stream-null
+A promise that, when forced, is a single object, distinguishable from
+all other objects, that represents the null stream.  @code{stream-null}
+is immutable and unique.
address@hidden defvr
+
address@hidden {Scheme Syntax} stream-cons object-expr stream-expr
+Creates a newly-allocated stream containing a promise that, when forced,
+is a @code{stream-pair} with @var{object-expr} in its @code{stream-car}
+and @var{stream-expr} in its @code{stream-cdr}.  Neither
address@hidden nor @var{stream-expr} is evaluated when
address@hidden is called.
+
+Once created, a @code{stream-pair} is immutable; there is no
address@hidden  or @code{stream-set-cdr!} that modifies an
+existing stream-pair.  There is no dotted-pair or improper stream as
+with lists.
address@hidden deffn
+
address@hidden {Scheme Procedure} stream? object
+Returns true if @var{object} is a stream, otherwise returns false.  If
address@hidden is a stream, its promise will not be forced.  If
address@hidden(stream? obj)} returns true, then one of @code{(stream-null? obj)}
+or @code{(stream-pair? obj)} will return true and the other will return
+false.
address@hidden deffn
+
address@hidden {Scheme Procedure} stream-null? object
+Returns true if @var{object} is the distinguished null stream, otherwise
+returns false.  If @var{object} is a stream, its promise will be forced.
address@hidden deffn
+
address@hidden {Scheme Procedure} stream-pair? object
+Returns true if @var{object} is a @code{stream-pair} constructed by
address@hidden, otherwise returns false.  If @var{object} is a
+stream, its promise will be forced.
address@hidden deffn
+
address@hidden {Scheme Procedure} stream-car stream
+Returns the object stored in the @code{stream-car} of @var{stream}.  An
+error is signalled if the argument is not a @code{stream-pair}.  This
+causes the @var{object-expr} passed to @code{stream-cons} to be
+evaluated if it had not yet been; the value is cached in case it is
+needed again.
address@hidden deffn
+
address@hidden {Scheme Procedure} stream-cdr stream
+Returns the stream stored in the @code{stream-cdr} of @var{stream}.  An
+error is signalled if the argument is not a @code{stream-pair}.
address@hidden deffn
+
address@hidden {Scheme Syntax} stream-lambda formals body @dots{}
+Creates a procedure that returns a promise to evaluate the @var{body} of
+the procedure.  The last @var{body} expression to be evaluated must
+yield a stream.  As with normal @code{lambda}, @var{formals} may be a
+single variable name, in which case all the formal arguments are
+collected into a single list, or a list of variable names, which may be
+null if there are no arguments, proper if there are an exact number of
+arguments, or dotted if a fixed number of arguments is to be followed by
+zero or more arguments collected into a list.  @var{Body} must contain
+at least one expression, and may contain internal definitions preceding
+any expressions to be evaluated.
address@hidden deffn
+
address@hidden
+(define strm123
+  (stream-cons 1
+    (stream-cons 2
+      (stream-cons 3
+        stream-null))))
+
+(stream-car strm123) @result{} 1
+(stream-car (stream-cdr strm123) @result{} 2
+
+(stream-pair?
+  (stream-cdr
+    (stream-cons (/ 1 0) stream-null))) @result{} #f
+
+(stream? (list 1 2 3)) @result{} #f
+
+(define iter
+  (stream-lambda (f x)
+    (stream-cons x (iter f (f x)))))
+
+(define nats (iter (lambda (x) (+ x 1)) 0))
+
+(stream-car (stream-cdr nats)) @result{} 1
+
+(define stream-add
+  (stream-lambda (s1 s2)
+    (stream-cons
+      (+ (stream-car s1) (stream-car s2))
+      (stream-add (stream-cdr s1)
+                  (stream-cdr s2)))))
+
+(define evens (stream-add nats nats))
+
+(stream-car evens) @result{} 0
+(stream-car (stream-cdr evens)) @result{} 2
+(stream-car (stream-cdr (stream-cdr evens))) @result{} 4
address@hidden example
+
address@hidden SRFI-41 Stream Library
address@hidden SRFI-41 Stream Library
+
address@hidden {Scheme Syntax} define-stream (name args @dots{}) body @dots{}
+Creates a procedure that returns a stream, and may appear anywhere a
+normal @code{define} may appear, including as an internal definition.
+It may contain internal definitions of its own.  The defined procedure
+takes arguments in the same way as @code{stream-lambda}.
address@hidden is syntactic sugar on @code{stream-lambda}; see
+also @code{stream-let}, which is also a sugaring of
address@hidden
+
+A simple version of @code{stream-map} that takes only a single input
+stream calls itself recursively:
+
address@hidden
+(define-stream (stream-map proc strm)
+  (if (stream-null? strm)
+      stream-null
+      (stream-cons
+        (proc (stream-car strm))
+        (stream-map proc (stream-cdr strm))))))
address@hidden example
address@hidden deffn
+
address@hidden {Scheme Procedure} list->stream list
+Returns a newly-allocated stream containing the elements from
address@hidden
address@hidden deffn
+
address@hidden {Scheme Procedure} port->stream [port]
+Returns a newly-allocated stream containing in its elements the
+characters on the port.  If @var{port} is not given it defaults to the
+current input port.  The returned stream has finite length and is
+terminated by @code{stream-null}.
+
+It looks like one use of @code{port->stream} would be this:
+
address@hidden
+(define s ;wrong!
+  (with-input-from-file filename
+    (lambda () (port->stream))))
address@hidden example
+
+But that fails, because @code{with-input-from-file} is eager, and closes
+the input port prematurely, before the first character is read.  To read
+a file into a stream, say:
+
address@hidden
+(define-stream (file->stream filename)
+  (let ((p (open-input-file filename)))
+    (stream-let loop ((c (read-char p)))
+      (if (eof-object? c)
+          (begin (close-input-port p)
+                 stream-null)
+          (stream-cons c
+            (loop (read-char p)))))))
address@hidden example
address@hidden deffn
+
address@hidden {Scheme Syntax} stream object-expr @dots{}
+Creates a newly-allocated stream containing in its elements the objects,
+in order.  The @var{object-expr}s are evaluated when they are accessed,
+not when the stream is created.  If no objects are given, as in
+(stream), the null stream is returned.  See also @code{list->stream}.
+
address@hidden
+(define strm123 (stream 1 2 3))
+
+; (/ 1 0) not evaluated when stream is created
+(define s (stream 1 (/ 1 0) -1))
address@hidden example
address@hidden deffn
+
address@hidden {Scheme Procedure} stream->list [n] stream
+Returns a newly-allocated list containing in its elements the first
address@hidden items in @var{stream}.  If @var{stream} has less than @var{n}
+items, all the items in the stream will be included in the returned
+list.  If @var{n} is not given it defaults to infinity, which means that
+unless @var{stream} is finite @code{stream->list} will never return.
+
address@hidden
+(stream->list 10
+  (stream-map (lambda (x) (* x x))
+    (stream-from 0)))
+  @result{} (0 1 4 9 16 25 36 49 64 81)
address@hidden example
address@hidden deffn
+
address@hidden {Scheme Procedure} stream-append stream @dots{}
+Returns a newly-allocated stream containing in its elements those
+elements contained in its input @var{stream}s, in order of input.  If
+any of the input streams is infinite, no elements of any of the
+succeeding input streams will appear in the output stream.  See also
address@hidden
address@hidden deffn
+
address@hidden {Scheme Procedure} stream-concat stream
+Takes a @var{stream} consisting of one or more streams and returns a
+newly-allocated stream containing all the elements of the input streams.
+If any of the streams in the input @var{stream} is infinite, any
+remaining streams in the input stream will never appear in the output
+stream.  See also @code{stream-append}.
address@hidden deffn
+
address@hidden {Scheme Procedure} stream-constant object @dots{}
+Returns a newly-allocated stream containing in its elements the
address@hidden, repeating in succession forever.
+
address@hidden
+(stream-constant 1) @result{} 1 1 1 @dots{}
+(stream-constant #t #f) @result{} #t #f #t #f #t #f @dots{}
address@hidden example
address@hidden deffn
+
address@hidden {Scheme Procedure} stream-drop n stream
+Returns the suffix of the input @var{stream} that starts at the next
+element after the first @var{n} elements.  The output stream shares
+structure with the input @var{stream}; thus, promises forced in one
+instance of the stream are also forced in the other instance of the
+stream.  If the input @var{stream} has less than @var{n} elements,
address@hidden returns the null stream.  See also
address@hidden
address@hidden deffn
+
address@hidden {Scheme Procedure} stream-drop-while pred stream
+Returns the suffix of the input @var{stream} that starts at the first
+element @var{x} for which @code{(pred x)} returns false.  The output
+stream shares structure with the input @var{stream}.  See also
address@hidden
address@hidden deffn
+
address@hidden {Scheme Procedure} stream-filter pred stream
+Returns a newly-allocated stream that contains only those elements
address@hidden of the input @var{stream} which satisfy the predicate
address@hidden
+
address@hidden
+(stream-filter odd? (stream-from 0))
+   @result{} 1 3 5 7 9 @dots{}
address@hidden example
address@hidden deffn
+
address@hidden {Scheme Procedure} stream-fold proc base stream
+Applies a binary procedure @var{proc} to @var{base} and the first
+element of @var{stream} to compute a new @var{base}, then applies the
+procedure to the new @var{base} and the next element of @var{stream} to
+compute a succeeding @var{base}, and so on, accumulating a value that is
+finally returned as the value of @code{stream-fold} when the end of the
+stream is reached.  @var{stream} must be finite, or @code{stream-fold}
+will enter an infinite loop.  See also @code{stream-scan}, which is
+similar to @code{stream-fold}, but useful for infinite streams.  For
+readers familiar with other functional languages, this is a left-fold;
+there is no corresponding right-fold, since right-fold relies on finite
+streams that are fully-evaluated, in which case they may as well be
+converted to a list.
address@hidden deffn
+
address@hidden {Scheme Procedure} stream-for-each proc stream @dots{}
+Applies @var{proc} element-wise to corresponding elements of the input
address@hidden for side-effects; it returns nothing.
address@hidden stops as soon as any of its input streams is
+exhausted.
address@hidden deffn
+
address@hidden {Scheme Procedure} stream-from first [step]
+Creates a newly-allocated stream that contains @var{first} as its first
+element and increments each succeeding element by @var{step}.  If
address@hidden is not given it defaults to 1.  @var{first} and @var{step}
+may be of any numeric type.  @code{stream-from} is frequently useful as
+a generator in @code{stream-of} expressions.  See also
address@hidden for a similar procedure that creates finite streams.
address@hidden deffn
+
address@hidden {Scheme Procedure} stream-iterate proc base
+Creates a newly-allocated stream containing @var{base} in its first
+element and applies @var{proc} to each element in turn to determine the
+succeeding element.  See also @code{stream-unfold} and
address@hidden
address@hidden deffn
+
address@hidden {Scheme Procedure} stream-length stream
+Returns the number of elements in the @var{stream}; it does not evaluate
+its elements.  @code{stream-length} may only be used on finite streams;
+it enters an infinite loop with infinite streams.
address@hidden deffn
+
address@hidden {Scheme Syntax} stream-let tag ((var expr) @dots{}) body @dots{}
+Creates a local scope that binds each variable to the value of its
+corresponding expression.  It additionally binds @var{tag} to a
+procedure which takes the bound variables as arguments and @var{body} as
+its defining expressions, binding the @var{tag} with
address@hidden  @var{tag} is in scope within body, and may be
+called recursively.  When the expanded expression defined by the
address@hidden is evaluated, @code{stream-let} evaluates the
+expressions in its @var{body} in an environment containing the
+newly-bound variables, returning the value of the last expression
+evaluated, which must yield a stream.
+
address@hidden provides syntactic sugar on @code{stream-lambda}, in
+the same manner as normal @code{let} provides syntactic sugar on normal
address@hidden  However, unlike normal @code{let}, the @var{tag} is
+required, not optional, because unnamed @code{stream-let} is
+meaningless.
+
+For example, @code{stream-member} returns the first @code{stream-pair}
+of the input @var{strm} with a @code{stream-car} @var{x} that satisfies
address@hidden(eql? obj x)}, or the null stream if @var{x} is not present in
address@hidden
+
address@hidden
+(define-stream (stream-member eql? obj strm)
+  (stream-let loop ((strm strm))
+    (cond ((stream-null? strm) strm)
+          ((eql? obj (stream-car strm)) strm)
+          (else (loop (stream-cdr strm))))))
address@hidden example
address@hidden deffn
+
address@hidden {Scheme Procedure} stream-map proc stream @dots{}
+Applies @var{proc} element-wise to corresponding elements of the input
address@hidden, returning a newly-allocated stream containing elements
+that are the results of those procedure applications.  The output stream
+has as many elements as the minimum-length input stream, and may be
+infinite.
address@hidden deffn
+
address@hidden {Scheme Syntax} stream-match stream clause @dots{}
+Provides pattern-matching for streams.  The input @var{stream} is an
+expression that evaluates to a stream.  Clauses are of the form
address@hidden(pattern [fender] expression)}, consisting of a @var{pattern} that
+matches a stream of a particular shape, an optional @var{fender} that
+must succeed if the pattern is to match, and an @var{expression} that is
+evaluated if the pattern matches.  There are four types of patterns:
+
address@hidden @bullet
address@hidden
+() matches the null stream.
+
address@hidden
+(@var{pat0} @var{pat1} @dots{}) matches a finite stream with length
+exactly equal to the number of pattern elements.
+
address@hidden
+(@var{pat0} @var{pat1} @dots{} @code{.} @var{pat-rest}) matches an
+infinite stream, or a finite stream with length at least as great as the
+number of pattern elements before the literal dot.
+
address@hidden
address@hidden matches an entire stream.  Should always appear last in the
+list of clauses; it's not an error to appear elsewhere, but subsequent
+clauses could never match.
address@hidden itemize
+
+Each pattern element may be either:
+
address@hidden @bullet
address@hidden
+An identifier, which matches any stream element.  Additionally, the
+value of the stream element is bound to the variable named by the
+identifier, which is in scope in the @var{fender} and @var{expression}
+of the corresponding @var{clause}.  Each identifier in a single pattern
+must be unique.
+
address@hidden
+A literal underscore (@code{_}), which matches any stream element but
+creates no bindings.
address@hidden itemize
+
+The @var{pattern}s are tested in order, left-to-right, until a matching
+pattern is found; if @var{fender} is present, it must evaluate to a true
+value for the match to be successful.  Pattern variables are bound in
+the corresponding @var{fender} and @var{expression}.  Once the matching
address@hidden is found, the corresponding @var{expression} is evaluated
+and returned as the result of the match.  An error is signaled if no
+pattern matches the input @var{stream}.
+
address@hidden is often used to distinguish null streams from
+non-null streams, binding @var{head} and @var{tail}:
+
address@hidden
+(define (len strm)
+  (stream-match strm
+    (() 0)
+    ((head . tail) (+ 1 (len tail)))))
address@hidden example
+
+Fenders can test the common case where two stream elements must be
+identical; the @code{else} pattern is an identifier bound to the entire
+stream, not a keyword as in @code{cond}.
+
address@hidden
+(stream-match strm
+  ((x y . _) (equal? x y) 'ok)
+  (else 'error))
address@hidden example
+
+A more complex example uses two nested matchers to match two different
+stream arguments; @code{(stream-merge lt? . strms)} stably merges two or
+more streams ordered by the @code{lt?} predicate:
+
address@hidden
+(define-stream (stream-merge lt? . strms)
+  (define-stream (merge xx yy)
+    (stream-match xx (() yy) ((x . xs)
+      (stream-match yy (() xx) ((y . ys)
+        (if (lt? y x)
+            (stream-cons y (merge xx ys))
+            (stream-cons x (merge xs yy))))))))
+  (stream-let loop ((strms strms))
+    (cond ((null? strms) stream-null)
+          ((null? (cdr strms)) (car strms))
+          (else (merge (car strms)
+                       (apply stream-merge lt?
+                         (cdr strms)))))))
address@hidden example
address@hidden deffn
+
address@hidden {Scheme Syntax} stream-of expr clause @dots{}
+Provides the syntax of stream comprehensions, which generate streams by
+means of looping expressions.  The result is a stream of objects of the
+type returned by @var{expr}.  There are four types of clauses:
+
address@hidden @bullet
address@hidden
+(@var{var} @code{in} @var{stream-expr}) loops over the elements of
address@hidden, in order from the start of the stream, binding each
+element of the stream in turn to @var{var}.  @code{stream-from} and
address@hidden are frequently useful as generators for
address@hidden
+
address@hidden
+(@var{var} @code{is} @var{expr}) binds @var{var} to the value obtained
+by evaluating @var{expr}.
+
address@hidden
+(@var{pred} @var{expr}) includes in the output stream only those
+elements @var{x} which satisfy the predicate @var{pred}.
address@hidden itemize
+
+The scope of variables bound in the stream comprehension is the clauses
+to the right of the binding clause (but not the binding clause itself)
+plus the result expression.
+
+When two or more generators are present, the loops are processed as if
+they are nested from left to right; that is, the rightmost generator
+varies fastest.  A consequence of this is that only the first generator
+may be infinite and all subsequent generators must be finite.  If no
+generators are present, the result of a stream comprehension is a stream
+containing the result expression; thus, @samp{(stream-of 1)} produces a
+finite stream containing only the element 1.
+
address@hidden
+(stream-of (* x x)
+  (x in (stream-range 0 10))
+  (even? x))
+  @result{} 0 4 16 36 64
+
+(stream-of (list a b)
+  (a in (stream-range 1 4))
+  (b in (stream-range 1 3)))
+  @result{} (1 1) (1 2) (2 1) (2 2) (3 1) (3 2)
+
+(stream-of (list i j)
+  (i in (stream-range 1 5))
+  (j in (stream-range (+ i 1) 5)))
+  @result{} (1 2) (1 3) (1 4) (2 3) (2 4) (3 4)
address@hidden example
address@hidden deffn
+
address@hidden {Scheme Procedure} stream-range first past [step]
+Creates a newly-allocated stream that contains @var{first} as its first
+element and increments each succeeding element by @var{step}.  The
+stream is finite and ends before @var{past}, which is not an element of
+the stream.  If @var{step} is not given it defaults to 1 if @var{first}
+is less than past and -1 otherwise.  @var{first}, @var{past} and
address@hidden may be of any real numeric type.  @code{stream-range} is
+frequently useful as a generator in @code{stream-of} expressions.  See
+also @code{stream-from} for a similar procedure that creates infinite
+streams.
+
address@hidden
+(stream-range 0 10) @result{} 0 1 2 3 4 5 6 7 8 9
+(stream-range 0 10 2) @result{} 0 2 4 6 8
address@hidden example
+
+Successive elements of the stream are calculated by adding @var{step} to
address@hidden, so if any of @var{first}, @var{past} or @var{step} are
+inexact, the length of the output stream may differ from
address@hidden(ceiling (- (/ (- past first) step) 1)}.
address@hidden deffn
+
address@hidden {Scheme Procedure} stream-ref stream n
+Returns the @var{n}th element of stream, counting from zero.  An error
+is signaled if @var{n} is greater than or equal to the length of stream.
+
address@hidden
+(define (fact n)
+  (stream-ref
+    (stream-scan * 1 (stream-from 1))
+    n))
address@hidden example
address@hidden deffn
+
address@hidden {Scheme Procedure} stream-reverse stream
+Returns a newly-allocated stream containing the elements of the input
address@hidden but in reverse order.  @code{stream-reverse} may only be
+used with finite streams; it enters an infinite loop with infinite
+streams.  @code{stream-reverse} does not force evaluation of the
+elements of the stream.
address@hidden deffn
+
address@hidden {Scheme Procedure} stream-scan proc base stream
+Accumulates the partial folds of an input @var{stream} into a
+newly-allocated output stream.  The output stream is the @var{base}
+followed by @code{(stream-fold proc base (stream-take i stream))} for
+each of the first @var{i} elements of @var{stream}.
+
address@hidden
+(stream-scan + 0 (stream-from 1))
+  @result{} (stream 0 1 3 6 10 15 @dots{})
+
+(stream-scan * 1 (stream-from 1))
+  @result{} (stream 1 1 2 6 24 120 @dots{})
address@hidden example
address@hidden deffn
+
address@hidden {Scheme Procedure} stream-take n stream
+Returns a newly-allocated stream containing the first @var{n} elements
+of the input @var{stream}.  If the input @var{stream} has less than
address@hidden elements, so does the output stream.  See also
address@hidden
address@hidden deffn
+
address@hidden {Scheme Procedure} stream-take-while pred stream
+Takes a predicate and a @code{stream} and returns a newly-allocated
+stream containing those elements @code{x} that form the maximal prefix
+of the input stream which satisfy @var{pred}.  See also
address@hidden
address@hidden deffn
+
address@hidden {Scheme Procedure} stream-unfold map pred gen base
+The fundamental recursive stream constructor.  It constructs a stream by
+repeatedly applying @var{gen} to successive values of @var{base}, in the
+manner of @code{stream-iterate}, then applying @var{map} to each of the
+values so generated, appending each of the mapped values to the output
+stream as long as @code{(pred? base)} returns a true value.  See also
address@hidden and @code{stream-unfolds}.
+
+The expression below creates the finite stream @samp{0 1 4 9 16 25 36 49
+64 81}.  Initially the @var{base} is 0, which is less than 10, so
address@hidden squares the @var{base} and the mapped value becomes the first
+element of the output stream.  Then @var{gen} increments the @var{base}
+by 1, so it becomes 1; this is less than 10, so @var{map} squares the
+new @var{base} and 1 becomes the second element of the output stream.
+And so on, until the base becomes 10, when @var{pred} stops the
+recursion and stream-null ends the output stream.
+
address@hidden
+(stream-unfold
+  (lambda (x) (expt x 2)) ; map
+  (lambda (x) (< x 10))   ; pred?
+  (lambda (x) (+ x 1))    ; gen
+  0)                      ; base
address@hidden example
address@hidden deffn
+
address@hidden {Scheme Procedure} stream-unfolds proc seed
+Returns @var{n} newly-allocated streams containing those elements
+produced by successive calls to the generator @var{proc}, which takes
+the current @var{seed} as its argument and returns @var{n}+1 values
+
+(@var{proc} @var{seed}) @result{} @var{seed} @var{result_0} @dots{} 
@var{result_n-1}
+
+where the returned @var{seed} is the input @var{seed} to the next call
+to the generator and @var{result_i} indicates how to produce the next
+element of the @var{i}th result stream:
+
address@hidden @bullet
address@hidden
+(@var{value}): @var{value} is the next car of the result stream.
+
address@hidden
address@hidden: no value produced by this iteration of the generator
address@hidden for the result stream.
+
address@hidden
+(): the end of the result stream.
address@hidden itemize
+
+It may require multiple calls of @var{proc} to produce the next element
+of any particular result stream.  See also @code{stream-iterate} and
address@hidden
+
address@hidden
+(define (stream-partition pred? strm)
+  (stream-unfolds
+    (lambda (s)
+      (if (stream-null? s)
+          (values s '() '())
+          (let ((a (stream-car s))
+                (d (stream-cdr s)))
+            (if (pred? a)
+                (values d (list a) #f)
+                (values d #f (list a))))))
+    strm))
+
+(call-with-values
+  (lambda ()
+    (stream-partition odd?
+      (stream-range 1 6)))
+  (lambda (odds evens)
+    (list (stream->list odds)
+          (stream->list evens))))
+  @result{} ((1 3 5) (2 4))
address@hidden example
address@hidden deffn
+
address@hidden {Scheme Procedure} stream-zip stream @dots{}
+Returns a newly-allocated stream in which each element is a list (not a
+stream) of the corresponding elements of the input @var{stream}s.  The
+output stream is as long as the shortest input @var{stream}, if any of
+the input @var{stream}s is finite, or is infinite if all the input
address@hidden are infinite.
address@hidden deffn
+
 @node SRFI-42
 @subsection SRFI-42 - Eager Comprehensions
 @cindex SRFI-42
@@ -3832,6 +4552,13 @@ words, no program that uses the R5RS definitions of 
delay and force will
 break if those definition are replaced by the SRFI-45 definitions of
 delay and force.
 
+Guile also adds @code{promise?} to the list of exports, which is not
+part of the official SRFI-45.
+
address@hidden {Scheme Procedure} promise? obj
+Return true if @var{obj} is an SRFI-45 promise, otherwise return false.
address@hidden deffn
+
 @deffn {Scheme Syntax} delay expression
 Takes an expression of arbitrary type @var{a} and returns a promise of
 type @code{(Promise @var{a})} which at some point in the future may be
diff --git a/doc/ref/sxml-match.texi b/doc/ref/sxml-match.texi
index 7a1a9ac..d2795a5 100644
--- a/doc/ref/sxml-match.texi
+++ b/doc/ref/sxml-match.texi
@@ -1,6 +1,6 @@
 @c -*-texinfo-*-
 @c This is part of the GNU Guile Reference Manual.
address@hidden Copyright (C) 2010  Free Software Foundation, Inc.
address@hidden Copyright (C) 2010, 2013  Free Software Foundation, Inc.
 @c See the file guile.texi for copying conditions.
 @c
 @c Based on the documentation at
@@ -16,10 +16,10 @@
 @cindex pattern matching (SXML)
 @cindex SXML pattern matching
 
-The @code{(sxml match)} module provides syntactic forms for pattern matching of
-SXML trees, in a ``by example'' style reminiscent of the pattern matching of 
the
address@hidden and @code{syntax-case} macro systems.  @xref{sxml simple,
-the @code{(sxml simple)} module}, for more information on SXML.
+The @code{(sxml match)} module provides syntactic forms for pattern
+matching of SXML trees, in a ``by example'' style reminiscent of the
+pattern matching of the @code{syntax-rules} and @code{syntax-case} macro
+systems.  @xref{SXML}, for more information on SXML.
 
 The following address@hidden example is taken from a paper by
 Krishnamurthi et al.  Their paper was the first to show the usefulness of the
diff --git a/doc/ref/sxml.texi b/doc/ref/sxml.texi
index 3ce6062..75867f3 100644
--- a/doc/ref/sxml.texi
+++ b/doc/ref/sxml.texi
@@ -6,257 +6,290 @@
 @node SXML
 @section SXML
 
address@hidden
-* sxml apply-templates::  A more XSLT-like approach to SXML transformations
-* sxml fold::            Fold-based SXML transformation operators
-* sxml simple::          Convenient XML parsing and serializing
-* sxml ssax::            Functional-style XML parsing for Scheme
-* sxml ssax input-parse::  The SSAX tokenizer, optimized for Guile
-* sxml transform::       A higher-order SXML transformation operator, 
@code{pre-post-order}
-* sxml xpath::           XPath for SXML
address@hidden menu
-
address@hidden sxml apply-templates
address@hidden (sxml apply-templates)
address@hidden Overview
-Pre-order traversal of a tree and creation of a new tree:
-
address@hidden 
-       apply-templates:: tree x <templates> -> <new-tree>
address@hidden smallexample
-
-where
-
address@hidden 
- <templates> ::= (<template> ...)
- <template>  ::= (<node-test> <node-test> ... <node-test> . <handler>)
- <node-test> ::= an argument to node-typeof? above
- <handler>   ::= <tree> -> <new-tree>
address@hidden smallexample
-
-This procedure does a @emph{normal}, pre-order traversal of an SXML
-tree. It walks the tree, checking at each node against the list of
-matching templates.
-
-If the match is found (which must be unique, i.e., unambiguous), the
-corresponding handler is invoked and given the current node as an
-argument. The result from the handler, which must be a @code{<tree>},
-takes place of the current node in the resulting tree. The name of the
-function is not accidental: it resembles rather closely an
address@hidden function of XSLT.
-
address@hidden Usage
address@hidden apply-templates address@hidden apply-templates tree templates
address@hidden defun
-
address@hidden sxml fold
address@hidden (sxml fold)
address@hidden Overview
address@hidden(sxml fold)} defines a number of variants of the @dfn{fold}
-algorithm for use in transforming SXML trees. Additionally it defines
-the layout operator, @code{fold-layout}, which might be described as a
-context-passing variant of SSAX's @code{pre-post-order}.
-
address@hidden Usage
address@hidden fold address@hidden foldt fup fhere tree
-The standard multithreaded tree fold.
-
address@hidden is of type [a] -> a. @var{fhere} is of type object -> a.
-
address@hidden defun
-
address@hidden fold address@hidden foldts fdown fup fhere seed tree
-The single-threaded tree fold originally defined in SSAX. @xref{sxml
-ssax,,(sxml ssax)}, for more information.
+SXML is a native representation of XML in terms of standard Scheme data
+types: lists, symbols, and strings.  For example, the simple XML
+fragment:
 
address@hidden defun
-
address@hidden fold address@hidden foldts* fdown fup fhere seed tree
-A variant of @ref{sxml fold foldts,,foldts} that allows pre-order tree
-rewrites. Originally defined in Andy Wingo's 2007 paper,
address@hidden of fold to XML transformation}.
-
address@hidden defun
-
address@hidden fold address@hidden fold-values proc list . seeds
-A variant of @ref{SRFI-1 Fold and Map,fold} that allows multi-valued
-seeds. Note that the order of the arguments differs from that of
address@hidden
-
address@hidden defun
-
address@hidden fold address@hidden foldts*-values fdown fup fhere tree . seeds
-A variant of @ref{sxml fold foldts*,,foldts*} that allows multi-valued
-seeds. Originally defined in Andy Wingo's 2007 paper, @emph{Applications
-of fold to XML transformation}.
-
address@hidden defun
-
address@hidden fold address@hidden fold-layout tree bindings params layout 
stylesheet
-A traversal combinator in the spirit of SSAX's @ref{sxml transform
-pre-post-order,,pre-post-order}.
-
address@hidden was originally presented in Andy Wingo's 2007 paper,
address@hidden of fold to XML transformation}.
-
address@hidden 
-bindings := (<binding>...)
-binding  := (<tag> <bandler-pair>...)
-          | (*default* . <post-handler>)
-          | (*text* . <text-handler>)
-tag      := <symbol>
-handler-pair := (pre-layout . <pre-layout-handler>)
-          | (post . <post-handler>)
-          | (bindings . <bindings>)
-          | (pre . <pre-handler>)
-          | (macro . <macro-handler>)
address@hidden
+<parrot type="African Grey"><name>Alfie</name></parrot>
 @end example
 
address@hidden @var
address@hidden pre-layout-handler
-A function of three arguments:
-
address@hidden @var
address@hidden kids
-the kids of the current node, before traversal
-
address@hidden params
-the params of the current node
-
address@hidden layout
-the layout coming into this node
-
address@hidden table
-
address@hidden is expected to use this information to return a
-layout to pass to the kids. The default implementation returns the
-layout given in the arguments.
+may be represented with the following SXML:
 
address@hidden post-handler
-A function of five arguments:
address@hidden
+(parrot (@@ (type "African Grey)) (name "Alfie"))
address@hidden example
 
address@hidden @var
address@hidden tag
-the current tag being processed
+SXML is very general, and is capable of representing all of XML.
+Formally, this means that SXML is a conforming implementation of the
address@hidden Information Set,http://www.w3.org/TR/xml-infoset/} standard.
 
address@hidden params
-the params of the current node
+Guile includes several facilities for working with XML and SXML:
+parsers, serializers, and transformers.
 
address@hidden layout
-the layout coming into the current node, before any kids were processed
address@hidden
+* SXML Overview::              XML, as it was meant to be
+* Reading and Writing XML::    Convenient XML parsing and serializing
+* SSAX::                       Custom functional-style XML parsers
+* Transforming SXML::          Munging SXML with @code{pre-post-order}
+* SXML Tree Fold::             Fold-based SXML transformations
+* SXPath::                     XPath for SXML
+* sxml apply-templates::       A more XSLT-like approach to SXML 
transformations
+* sxml ssax input-parse::      The SSAX tokenizer, optimized for Guile
address@hidden menu
 
address@hidden klayout
-the layout after processing all of the children
address@hidden SXML Overview
address@hidden SXML Overview
 
address@hidden kids
-the already-processed child nodes
+(This section needs to be written; volunteers welcome.)
 
address@hidden table
 
address@hidden should return two values, the layout to pass to the
-next node and the final tree.
address@hidden Reading and Writing XML
address@hidden Reading and Writing XML
 
address@hidden text-handler
address@hidden is a function of three arguments:
+The @code{(sxml simple)} module presents a basic interface for parsing
+XML from a port into the Scheme SXML format, and for serializing it back
+to text.
 
address@hidden @var
address@hidden text
-the string
address@hidden
+(use-modules (sxml simple))
address@hidden example
 
address@hidden params
-the current params
address@hidden {Scheme Procedure} xml->sxml [string-or-port] [#:namespaces='()] 
@
+       [#:declare-namespaces?=#t] [#:trim-whitespace?=#f] @
+       [#:entities='()] [#:default-entity-handler=#f] @
+       [#:doctype-handler=#f]
+Use SSAX to parse an XML document into SXML. Takes one optional
+argument, @var{string-or-port}, which defaults to the current input
+port.  Returns the resulting SXML document.  If @var{string-or-port} is
+a port, it will be left pointing at the next available character in the
+port.
address@hidden deffn
+
+As is normal in SXML, XML elements parse as tagged lists.  Attributes,
+if any, are placed after the tag, within an @code{@@} element.  The root
+of the resulting XML will be contained in a special tag, @code{*TOP*}.
+This tag will contain the root element of the XML, but also any prior
+processing instructions.
+
address@hidden
+(xml->sxml "<foo/>")
address@hidden (*TOP* (foo))
+(xml->sxml "<foo>text</foo>")
address@hidden (*TOP* (foo "text"))
+(xml->sxml "<foo kind=\"bar\">text</foo>")
address@hidden (*TOP* (foo (@@ (kind "bar")) "text"))
+(xml->sxml "<?xml version=\"1.0\"?><foo/>")
address@hidden (*TOP* (*PI* xml "version=\"1.0\"") (foo))
address@hidden example
 
address@hidden layout
-the current layout
+All namespaces in the XML document must be declared, via @code{xmlns}
+attributes.  SXML elements built from non-default namespaces will have
+their tags prefixed with their URI.  Users can specify custom prefixes
+for certain namespaces with the @code{#:namespaces} keyword argument to
address@hidden>sxml}.
+
address@hidden
+(xml->sxml "<foo xmlns=\"http://example.org/ns1\";>text</foo>")
address@hidden (*TOP* (http://example.org/ns1:foo "text"))
+(xml->sxml "<foo xmlns=\"http://example.org/ns1\";>text</foo>"
+           #:namespaces '((ns1 . "http://example.org/ns1";)))
address@hidden (*TOP* (ns1:foo "text"))
+(xml->sxml "<foo xmlns:bar=\"http://example.org/ns2\";><bar:baz/></foo>"
+           #:namespaces '((ns2 . "http://example.org/ns2";)))
address@hidden (*TOP* (foo (ns2:baz)))
address@hidden example
 
address@hidden table
+By default, namespaces passed to @code{xml->sxml} are treated as if they
+were declared on the root element.  Passing a false
address@hidden:declare-namespaces?} argument will disable this behavior,
+requiring in-document declarations of namespaces before use..
+
address@hidden
+(xml->sxml "<foo><ns2:baz/></foo>"
+           #:namespaces '((ns2 . "http://example.org/ns2";)))
address@hidden (*TOP* (foo (ns2:baz)))
+(xml->sxml "<foo><ns2:baz/></foo>"
+           #:namespaces '((ns2 . "http://example.org/ns2";))
+           #:declare-namespaces? #f)
address@hidden error: undeclared namespace: `bar'
address@hidden example
 
address@hidden should return two values, the layout to pass to the
-next node and the value to which the string should transform.
+By default, all whitespace in XML is significant.  Passing the
address@hidden:trim-whitespace?} keyword argument to @code{xml->sxml} will trim
+whitespace in front, behind and between elements, treating it as
+``unsignificant''.  Whitespace in text fragments is left alone.
+
address@hidden
+(xml->sxml "<foo>\n<bar> Alfie the parrot! </bar>\n</foo>")
address@hidden (*TOP* (foo "\n" (bar " Alfie the parrot! ") "\n"))
+(xml->sxml "<foo>\n<bar> Alfie the parrot! </bar>\n</foo>"
+           #:trim-whitespace? #t)
address@hidden (*TOP* (foo (bar " Alfie the parrot! ")))
address@hidden example
 
address@hidden table
+Parsed entities may be declared with the @code{#:entities} keyword
+argument, or handled with the @code{#:default-entity-handler}.  By
+default, only the standard @code{&lt;}, @code{&gt;}, @code{&amp;},
address@hidden&apos;} and @code{&quot;} entities are defined, as well as the
address@hidden&address@hidden;} and @code{&address@hidden;} (decimal and 
hexadecimal)
+numeric character entities.
+
address@hidden
+(xml->sxml "<foo>&amp;</foo>")
address@hidden (*TOP* (foo "&"))
+(xml->sxml "<foo>&nbsp;</foo>")
address@hidden error: undefined entity: nbsp
+(xml->sxml "<foo>&#xA0;</foo>")
address@hidden (*TOP* (foo "\xa0"))
+(xml->sxml "<foo>&nbsp;</foo>"
+           #:entities '((nbsp . "\xa0")))
address@hidden (*TOP* (foo "\xa0"))
+(xml->sxml "<foo>&nbsp; &foo;</foo>"
+           #:default-entity-handler
+           (lambda (port name)
+             (case name
+               ((nbsp) "\xa0")
+               (else
+                (format (current-warning-port)
+                        "~a:~a:~a: undefined entitity: ~a\n"
+                        (or (port-filename port) "<unknown file>")
+                        (port-line port) (port-column port)
+                        name)
+                (symbol->string name)))))
address@hidden <unknown file>:0:17: undefined entitity: foo
address@hidden (*TOP* (foo "\xa0 foo"))
address@hidden example
 
address@hidden defun
+By default, @code{xml->sxml} skips over the @code{<!DOCTYPE>}
+declaration, if any.  This behavior can be overridden with the
address@hidden:doctype-handler} argument, which should be a procedure of three
+arguments: the @dfn{docname} (a symbol), @dfn{systemid} (a string), and
+the internal doctype subset (as a string or @code{#f} if not present).
+
+The handler should return keyword arguments as multiple values, as if it
+were calling its continuation with keyword arguments.  The continuation
+accepts the @code{#:entities} and @code{#:namespaces} keyword arguments,
+in the same format that @code{xml->sxml} itself takes.  These entities
+and namespaces will be prepended to those given to the @code{xml->sxml}
+invocation.
+
address@hidden
+(define (handle-foo docname systemid internal-subset)
+  (case docname
+    ((foo)
+     (values #:entities '((greets . "<i>Hello, world!</i>"))))
+    (else
+     (values))))
+
+(xml->sxml "<!DOCTYPE foo><p>&greets;</p>"
+           #:doctype-handler handle-foo)
address@hidden (*TOP* (p (i "Hello, world!")))
address@hidden example
 
address@hidden sxml simple
address@hidden (sxml simple)
address@hidden Overview
-A simple interface to XML parsing and serialization.
+If the document has no doctype declaration, the @var{doctype-handler} is
+invoked with @code{#f} for the three arguments.
 
address@hidden Usage
address@hidden simple xml->address@hidden xml->sxml [port]
-Use SSAX to parse an XML document into SXML. Takes one optional
-argument, @var{port}, which defaults to the current input port.
-
address@hidden defun
+In the future, the continuation may accept other keyword arguments, for
+example to validate the parsed SXML against the doctype.
 
address@hidden simple sxml->address@hidden sxml->xml tree [port]
-Serialize the sxml tree @var{tree} as XML. The output will be written to
address@hidden {Scheme Procedure} sxml->xml tree [port]
+Serialize the SXML tree @var{tree} as XML. The output will be written to
 the current output port, unless the optional argument @var{port} is
 present.
address@hidden deffn
 
address@hidden defun
-
address@hidden simple sxml->address@hidden sxml->string sxml
address@hidden {Scheme Procedure} sxml->string sxml
 Detag an sxml tree @var{sxml} into a string. Does not perform any
 formatting.
-
address@hidden defun
-
address@hidden sxml ssax
address@hidden (sxml ssax)
address@hidden Overview
address@hidden Functional XML parsing framework
address@hidden SAX/DOM and SXML parsers with support for XML Namespaces and 
validation
-This is a package of low-to-high level lexing and parsing procedures
-that can be combined to yield a SAX, a DOM, a validating parser, or a
-parser intended for a particular document type. The procedures in the
-package can be used separately to tokenize or parse various pieces of
-XML documents. The package supports XML Namespaces, internal and
-external parsed entities, user-controlled handling of whitespace, and
-validation. This module therefore is intended to be a framework, a set
-of "Lego blocks" you can use to build a parser following any discipline
-and performing validation to any degree. As an example of the parser
-construction, this file includes a semi-validating SXML parser.
-
-The present XML framework has a "sequential" feel of SAX yet a
-"functional style" of DOM. Like a SAX parser, the framework scans the
-document only once and permits incremental processing. An application
-that handles document elements in order can run as efficiently as
-possible. @emph{Unlike} a SAX parser, the framework does not require an
-application register stateful callbacks and surrender control to the
-parser. Rather, it is the application that can drive the framework --
-calling its functions to get the current lexical or syntax element.
-These functions do not maintain or mutate any state save the input port.
-Therefore, the framework permits parsing of XML in a pure functional
-style, with the input port being a monad (or a linear, read-once
-parameter).
-
-Besides the @var{port}, there is another monad -- @var{seed}. Most of
address@hidden deffn
+
address@hidden SSAX
address@hidden SSAX: A Functional XML Parsing Toolkit
+
+Guile's XML parser is based on Oleg Kiselyov's powerful XML parsing
+toolkit, SSAX.
+
address@hidden History
+
+Back in the 1990s, when the world was young again and XML was the
+solution to all of its problems, there were basically two kinds of XML
+parsers out there: DOM parsers and SAX parsers.
+
+A DOM parser reads through an entire XML document, building up a tree of
+``DOM objects'' representing the document structure.  They are very easy
+to use, but sometimes you don't actually want all of the information in
+a document; building an object tree is not necessary if all you want to
+do is to count word frequencies in a document, for example.
+
+SAX parsers were created to give the programmer more control on the
+parsing process.  A programmer gives the SAX parser a number of
+``callbacks'': functions that will be called on various features of the
+XML stream as they are encountered.  SAX parsers are more efficient, but
+much harder to user, as users typically have to manually maintain a
+stack of open elements.
+
+Kiselyov realized that the SAX programming model could be made much
+simpler if the callbacks were formulated not as a linear fold across the
+features of the XML stream, but as a @emph{tree fold} over the structure
+implicit in the XML.  In this way, the user has a very convenient,
+functional-style interface that can still generate optimal parsers.
+
+The @code{xml->sxml} interface from the @code{(sxml simple)} module is a
+DOM-style parser built using SSAX, though it returns SXML instead of DOM
+objects.
+
address@hidden Implementation
+
address@hidden(sxml ssax)} is a package of low-to-high level lexing and parsing
+procedures that can be combined to yield a SAX, a DOM, a validating
+parser, or a parser intended for a particular document type.  The
+procedures in the package can be used separately to tokenize or parse
+various pieces of XML documents.  The package supports XML Namespaces,
+internal and external parsed entities, user-controlled handling of
+whitespace, and validation.  This module therefore is intended to be a
+framework, a set of ``Lego blocks'' you can use to build a parser
+following any discipline and performing validation to any degree.  As an
+example of the parser construction, this file includes a semi-validating
+SXML parser.
+
+SSAX has a ``sequential'' feel of SAX yet a ``functional style'' of DOM.
+Like a SAX parser, the framework scans the document only once and
+permits incremental processing.  An application that handles document
+elements in order can run as efficiently as possible.  @emph{Unlike} a
+SAX parser, the framework does not require an application register
+stateful callbacks and surrender control to the parser.  Rather, it is
+the application that can drive the framework -- calling its functions to
+get the current lexical or syntax element.  These functions do not
+maintain or mutate any state save the input port.  Therefore, the
+framework permits parsing of XML in a pure functional style, with the
+input port being a monad (or a linear, read-once parameter).
+
+Besides the @var{port}, there is another monad -- @var{seed}.  Most of
 the middle- and high-level parsers are single-threaded through the
address@hidden The functions of this framework do not process or affect the
address@hidden in any way: they simply pass it around as an instance of an
-opaque datatype. User functions, on the other hand, can use the seed to
-maintain user's state, to accumulate parsing results, etc. A user can
-freely mix his own functions with those of the framework. On the other
-hand, the user may wish to instantiate a high-level parser:
address@hidden:make-elem-parser} or @code{SSAX:make-parser}. In the latter
address@hidden  The functions of this framework do not process or affect
+the @var{seed} in any way: they simply pass it around as an instance of
+an opaque datatype.  User functions, on the other hand, can use the seed
+to maintain user's state, to accumulate parsing results, etc.  A user
+can freely mix his own functions with those of the framework.  On the
+other hand, the user may wish to instantiate a high-level parser:
address@hidden:make-elem-parser} or @code{SSAX:make-parser}.  In the latter
 case, the user must provide functions of specific signatures, which are
 called at predictable moments during the parsing: to handle character
-data, element data, or processing instructions (PI). The functions are
+data, element data, or processing instructions (PI).  The functions are
 always given the @var{seed}, among other parameters, and must return the
 new @var{seed}.
 
 From a functional point of view, XML parsing is a combined
-pre-post-order traversal of a "tree" that is the XML document itself.
+pre-post-order traversal of a ``tree'' that is the XML document itself.
 This down-and-up traversal tells the user about an element when its
-start tag is encountered. The user is notified about the element once
-more, after all element's children have been handled. The process of XML
-parsing therefore is a fold over the raw XML document. Unlike a fold
-over trees defined in [1], the parser is necessarily single-threaded --
-obviously as elements in a text XML document are laid down sequentially.
-The parser therefore is a tree fold that has been transformed to accept
-an accumulating parameter [1,2].
+start tag is encountered.  The user is notified about the element once
+more, after all element's children have been handled.  The process of
+XML parsing therefore is a fold over the raw XML document.  Unlike a
+fold over trees defined in [1], the parser is necessarily
+single-threaded -- obviously as elements in a text XML document are laid
+down sequentially.  The parser therefore is a tree fold that has been
+transformed to accept an accumulating parameter [1,2].
 
 Formally, the denotational semantics of the parser can be expressed as
 
@@ -287,20 +320,22 @@ The real parser created by @code{SSAX:make-parser} is 
slightly more
 complicated, to account for processing instructions, entity references,
 namespaces, processing of document type declaration, etc.
 
-The XML standard document referred to in this module
address@hidden://www.w3.org/TR/1998/REC-xml-19980210.html}
+The XML standard document referred to in this module is
address@hidden://www.w3.org/TR/1998/REC-xml-19980210.html}
 
 The present file also defines a procedure that parses the text of an XML
 document or of a separate element into SXML, an S-expression-based model
-of an XML Information Set. SXML is also an Abstract Syntax Tree of an
-XML document. SXML is similar but not identical to DOM; SXML is
+of an XML Information Set.  SXML is also an Abstract Syntax Tree of an
+XML document.  SXML is similar but not identical to DOM; SXML is
 particularly suitable for Scheme-based XML/HTML authoring, SXPath
-queries, and tree transformations. See SXML.html for more details. SXML
-is a term implementation of evaluation of the XML document [3]. The
-other implementation is context-passing.
+queries, and tree transformations.  See SXML.html for more details.
+SXML is a term implementation of evaluation of the XML document [3].
+The other implementation is context-passing.
 
-The present frameworks fully supports the XML Namespaces
-Recommendation:@uref{http://www.w3.org/TR/REC-xml-names/} Other links:
+The present frameworks fully supports the XML Namespaces Recommendation:
address@hidden://www.w3.org/TR/REC-xml-names/}.
+
+Other links:
 
 @table @asis
 @item [1]
@@ -319,175 +354,104 @@ Pearl. Proc ICFP'00, pp. 186-197.
 @end table
 
 @subsubsection Usage
address@hidden ssax address@hidden current-ssax-error-port 
address@hidden defun
address@hidden {Scheme Procedure} current-ssax-error-port 
address@hidden deffn
 
address@hidden ssax address@hidden with-ssax-error-to-port port thunk
address@hidden defun
address@hidden {Scheme Procedure} with-ssax-error-to-port port thunk
address@hidden deffn
 
address@hidden ssax address@hidden xml-token? _
address@hidden {Scheme Procedure} xml-token? _
 @verbatim 
  -- Scheme Procedure: pair? x
      Return `#t' if X is a pair; otherwise return `#f'.
 
  
 @end verbatim
address@hidden deffn
 
address@hidden defun
-
address@hidden ssax address@hidden xml-token-kind token
address@hidden defspec
address@hidden {Scheme Syntax} xml-token-kind token
address@hidden deffn
 
address@hidden ssax address@hidden xml-token-head token
address@hidden defspec
address@hidden {Scheme Syntax} xml-token-head token
address@hidden deffn
 
address@hidden ssax address@hidden make-empty-attlist 
address@hidden defun
address@hidden {Scheme Procedure} make-empty-attlist 
address@hidden deffn
 
address@hidden ssax address@hidden attlist-add attlist name-value
address@hidden defun
address@hidden {Scheme Procedure} attlist-add attlist name-value
address@hidden deffn
 
address@hidden ssax address@hidden attlist-null? _
address@hidden 
- -- Scheme Procedure: null? x
-     Return `#t' iff X is the empty list, else `#f'.
address@hidden {Scheme Procedure} attlist-null? x
+Return @code{#t} if @var{x} is the empty list, else @code{#f}.
address@hidden deffn
 
- 
address@hidden verbatim
address@hidden {Scheme Procedure} attlist-remove-top attlist
address@hidden deffn
 
address@hidden defun
address@hidden {Scheme Procedure} attlist->alist attlist
address@hidden deffn
 
address@hidden ssax address@hidden attlist-remove-top attlist
address@hidden defun
address@hidden {Scheme Procedure} attlist-fold kons knil lis1
address@hidden deffn
 
address@hidden ssax attlist->address@hidden attlist->alist attlist
address@hidden defun
-
address@hidden ssax address@hidden attlist-fold kons knil lis1
address@hidden defun
-
address@hidden ssax address@hidden define-parsed-entity! entity str
-Define a new parsed entity. @var{entity} should be a symbol.
address@hidden {Scheme Procedure} define-parsed-entity! entity str
+Define a new parsed entity.  @var{entity} should be a symbol.
 
 Instances of &@var{entity}; in XML text will be replaced with the string
 @var{str}, which will then be parsed.
address@hidden deffn
 
address@hidden defun
-
address@hidden ssax address@hidden reset-parsed-entity-definitions! 
address@hidden {Scheme Procedure} reset-parsed-entity-definitions! 
 Restore the set of parsed entity definitions to its initial state.
address@hidden deffn
 
address@hidden defun
-
address@hidden ssax ssax:uri-string->address@hidden ssax:uri-string->symbol 
uri-str
address@hidden defun
-
address@hidden ssax ssax:address@hidden ssax:skip-internal-dtd port
address@hidden defun
-
address@hidden ssax ssax:address@hidden ssax:read-pi-body-as-string port
address@hidden defun
-
address@hidden ssax ssax:address@hidden ssax:reverse-collect-str-drop-ws 
fragments
address@hidden defun
-
address@hidden ssax ssax:address@hidden ssax:read-markup-token port
address@hidden defun
-
address@hidden ssax ssax:address@hidden ssax:read-cdata-body port str-handler 
seed
address@hidden defun
-
address@hidden ssax ssax:address@hidden ssax:read-char-ref port
address@hidden defun
address@hidden {Scheme Procedure} ssax:uri-string->symbol uri-str
address@hidden deffn
 
address@hidden ssax ssax:address@hidden ssax:read-attributes port entities
address@hidden defun
-
address@hidden ssax ssax:address@hidden ssax:complete-start-tag tag-head port 
elems entities namespaces
address@hidden defun
-
address@hidden ssax ssax:address@hidden ssax:read-external-id port
address@hidden defun
-
address@hidden ssax ssax:address@hidden ssax:read-char-data port expect-eof? 
str-handler seed
address@hidden defun
-
address@hidden ssax ssax:xml->address@hidden ssax:xml->sxml port 
namespace-prefix-assig
address@hidden defun
-
address@hidden ssax ssax:address@hidden ssax:make-parser  . kw-val-pairs
address@hidden defspec
-
address@hidden ssax ssax:address@hidden ssax:make-pi-parser orig-handlers
address@hidden defspec
-
address@hidden ssax ssax:address@hidden ssax:make-elem-parser my-new-level-seed 
my-finish-element my-char-data-handler my-pi-handlers
address@hidden defspec
-
address@hidden sxml ssax input-parse
address@hidden (sxml ssax input-parse)
address@hidden Overview
-A simple lexer.
-
-The procedures in this module surprisingly often suffice to parse an
-input stream. They either skip, or build and return tokens, according to
-inclusion or delimiting semantics. The list of characters to expect,
-include, or to break at may vary from one invocation of a function to
-another. This allows the functions to easily parse even
-context-sensitive languages.
-
-EOF is generally frowned on, and thrown up upon if encountered.
-Exceptions are mentioned specifically. The list of expected characters
-(characters to skip until, or break-characters) may include an EOF
-"character", which is to be coded as the symbol, @code{*eof*}.
address@hidden {Scheme Procedure} ssax:skip-internal-dtd port
address@hidden deffn
 
-The input stream to parse is specified as a @dfn{port}, which is usually
-the last (and optional) argument. It defaults to the current input port
-if omitted.
address@hidden {Scheme Procedure} ssax:read-pi-body-as-string port
address@hidden deffn
 
-If the parser encounters an error, it will throw an exception to the key
address@hidden The arguments will be of the form @code{(@var{port}
address@hidden @var{specialising-msg}*)}.
address@hidden {Scheme Procedure} ssax:reverse-collect-str-drop-ws fragments
address@hidden deffn
 
-The first argument is a port, which typically points to the offending
-character or its neighborhood. You can then use @code{port-column} and
address@hidden to query the current position. @var{message} is the
-description of the error. Other arguments supply more details about the
-problem.
address@hidden {Scheme Procedure} ssax:read-markup-token port
address@hidden deffn
 
address@hidden Usage
address@hidden ssax input-parse address@hidden peek-next-char [port]
address@hidden defun
address@hidden {Scheme Procedure} ssax:read-cdata-body port str-handler seed
address@hidden deffn
 
address@hidden ssax input-parse address@hidden assert-curr-char expected-chars 
comment [port]
address@hidden defun
address@hidden {Scheme Procedure} ssax:read-char-ref port
address@hidden deffn
 
address@hidden ssax input-parse address@hidden skip-until arg [port]
address@hidden defun
address@hidden {Scheme Procedure} ssax:read-attributes port entities
address@hidden deffn
 
address@hidden ssax input-parse address@hidden skip-while skip-chars [port]
address@hidden defun
address@hidden {Scheme Procedure} ssax:complete-start-tag tag-head port elems 
entities namespaces
address@hidden deffn
 
address@hidden ssax input-parse address@hidden next-token prefix-skipped-chars 
break-chars [comment] [port]
address@hidden defun
address@hidden {Scheme Procedure} ssax:read-external-id port
address@hidden deffn
 
address@hidden ssax input-parse address@hidden next-token-of incl-list/pred 
[port]
address@hidden defun
address@hidden {Scheme Procedure} ssax:read-char-data port expect-eof? 
str-handler seed
address@hidden deffn
 
address@hidden ssax input-parse address@hidden read-text-line [port]
address@hidden defun
address@hidden {Scheme Procedure} ssax:xml->sxml port namespace-prefix-assig
address@hidden deffn
 
address@hidden ssax input-parse address@hidden read-string n [port]
address@hidden defun
address@hidden {Scheme Syntax} ssax:make-parser . kw-val-pairs
address@hidden deffn
 
address@hidden ssax input-parse address@hidden find-string-from-port? _ _ . _
-Looks for @var{str} in @var{<input-port>}, optionally within the first
address@hidden characters.
address@hidden {Scheme Syntax} ssax:make-pi-parser orig-handlers
address@hidden deffn
 
address@hidden defun
address@hidden {Scheme Syntax} ssax:make-elem-parser my-new-level-seed 
my-finish-element my-char-data-handler my-pi-handlers
address@hidden deffn
 
address@hidden sxml transform
address@hidden (sxml transform)
address@hidden Transforming SXML
address@hidden Transforming SXML
 @subsubsection Overview
 @heading SXML expression tree transformers
 @subheading Pre-Post-order traversal of a tree and creation of a new tree
@@ -508,11 +472,11 @@ where
 @end smallexample
 
 The pre-post-order function visits the nodes and nodelists
-pre-post-order (depth-first). For each @code{<Node>} of the form
+pre-post-order (depth-first).  For each @code{<Node>} of the form
 @code{(@var{name} <Node> ...)}, it looks up an association with the
-given @var{name} among its @var{<bindings>}. If failed,
address@hidden tries to locate a @code{*default*} binding. It's
-an error if the latter attempt fails as well. Having found a binding,
+given @var{name} among its @var{<bindings>}.  If failed,
address@hidden tries to locate a @code{*default*} binding.  It's
+an error if the latter attempt fails as well.  Having found a binding,
 the @code{pre-post-order} function first checks to see if the binding is
 of the form
 
@@ -520,14 +484,14 @@ of the form
        (<trigger-symbol> *preorder* . <handler>)
 @end smallexample
 
-If it is, the handler is 'applied' to the current node. Otherwise, the
+If it is, the handler is 'applied' to the current node.  Otherwise, the
 pre-post-order function first calls itself recursively for each child of
 the current node, with @var{<new-bindings>} prepended to the
address@hidden<bindings>} in effect. The result of these calls is passed to the
address@hidden<handler>} (along with the head of the current @var{<Node>}). To 
be
address@hidden<bindings>} in effect.  The result of these calls is passed to the
address@hidden<handler>} (along with the head of the current @var{<Node>}).  To 
be
 more precise, the handler is _applied_ to the head of the current node
-and its processed children. The result of the handler, which should also
-be a @code{<tree>}, replaces the current @var{<Node>}. If the current
+and its processed children.  The result of the handler, which should also
+be a @code{<tree>}, replaces the current @var{<Node>}.  If the current
 @var{<Node>} is a text string or other atom, a special binding with a
 symbol @code{*text*} is looked up.
 
@@ -537,60 +501,182 @@ A binding can also be of a form
        (<trigger-symbol> *macro* . <handler>)
 @end smallexample
 
-This is equivalent to @code{*preorder*} described above. However, the
+This is equivalent to @code{*preorder*} described above.  However, the
 result is re-processed again, with the current stylesheet.
 
 @subsubsection Usage
address@hidden transform SRV:address@hidden SRV:send-reply . fragments
address@hidden {Scheme Procedure} SRV:send-reply . fragments
 Output the @var{fragments} to the current output port.
 
 The fragments are a list of strings, characters, numbers, thunks,
address@hidden, @code{#t} -- and other fragments. The function traverses the
address@hidden, @code{#t} -- and other fragments.  The function traverses the
 tree depth-first, writes out strings and characters, executes thunks,
-and ignores @code{#f} and @code{'()}. The function returns @code{#t} if
+and ignores @code{#f} and @code{'()}.  The function returns @code{#t} if
 anything was written at all; otherwise the result is @code{#f} If
 @code{#t} occurs among the fragments, it is not written out but causes
 the result of @code{SRV:send-reply} to be @code{#t}.
address@hidden deffn
+
address@hidden {Scheme Procedure} foldts fdown fup fhere seed tree
address@hidden deffn
+
address@hidden {Scheme Procedure} post-order tree bindings
address@hidden deffn
+
address@hidden {Scheme Procedure} pre-post-order tree bindings
address@hidden deffn
+
address@hidden {Scheme Procedure} replace-range beg-pred end-pred forest
address@hidden deffn
+
address@hidden SXML Tree Fold
address@hidden SXML Tree Fold
address@hidden Overview
address@hidden(sxml fold)} defines a number of variants of the @dfn{fold}
+algorithm for use in transforming SXML trees.  Additionally it defines
+the layout operator, @code{fold-layout}, which might be described as a
+context-passing variant of SSAX's @code{pre-post-order}.
+
address@hidden Usage
address@hidden {Scheme Procedure} foldt fup fhere tree
+The standard multithreaded tree fold.
+
address@hidden is of type [a] -> a. @var{fhere} is of type object -> a.
address@hidden deffn
+
address@hidden {Scheme Procedure} foldts fdown fup fhere seed tree
+The single-threaded tree fold originally defined in SSAX.  @xref{SSAX},
+for more information.
address@hidden deffn
+
address@hidden {Scheme Procedure} foldts* fdown fup fhere seed tree
+A variant of @code{foldts} that allows pre-order tree
+rewrites.  Originally defined in Andy Wingo's 2007 paper,
address@hidden of fold to XML transformation}.
address@hidden deffn
+
address@hidden {Scheme Procedure} fold-values proc list . seeds
+A variant of @code{fold} that allows multi-valued seeds.  Note that the
+order of the arguments differs from that of @code{fold}.  @xref{SRFI-1
+Fold and Map}.
address@hidden deffn
+
address@hidden {Scheme Procedure} foldts*-values fdown fup fhere tree . seeds
+A variant of @code{foldts*} that allows multi-valued
+seeds.  Originally defined in Andy Wingo's 2007 paper, @emph{Applications
+of fold to XML transformation}.
address@hidden deffn
+
address@hidden {Scheme Procedure} fold-layout tree bindings params layout 
stylesheet
+A traversal combinator in the spirit of @code{pre-post-order}.
address@hidden SXML}.
+
address@hidden was originally presented in Andy Wingo's 2007 paper,
address@hidden of fold to XML transformation}.
+
address@hidden 
+bindings := (<binding>...)
+binding  := (<tag> <bandler-pair>...)
+          | (*default* . <post-handler>)
+          | (*text* . <text-handler>)
+tag      := <symbol>
+handler-pair := (pre-layout . <pre-layout-handler>)
+          | (post . <post-handler>)
+          | (bindings . <bindings>)
+          | (pre . <pre-handler>)
+          | (macro . <macro-handler>)
address@hidden example
+
address@hidden @var
address@hidden pre-layout-handler
+A function of three arguments:
+
address@hidden @var
address@hidden kids
+the kids of the current node, before traversal
+
address@hidden params
+the params of the current node
+
address@hidden layout
+the layout coming into this node
+
address@hidden table
+
address@hidden is expected to use this information to return a
+layout to pass to the kids.  The default implementation returns the
+layout given in the arguments.
 
address@hidden defun
address@hidden post-handler
+A function of five arguments:
 
address@hidden transform address@hidden foldts fdown fup fhere seed tree
address@hidden defun
address@hidden @var
address@hidden tag
+the current tag being processed
 
address@hidden transform address@hidden post-order tree bindings
address@hidden defun
address@hidden params
+the params of the current node
 
address@hidden transform address@hidden pre-post-order tree bindings
address@hidden defun
address@hidden layout
+the layout coming into the current node, before any kids were processed
 
address@hidden transform address@hidden replace-range beg-pred end-pred forest
address@hidden defun
address@hidden klayout
+the layout after processing all of the children
+
address@hidden kids
+the already-processed child nodes
+
address@hidden table
+
address@hidden should return two values, the layout to pass to the
+next node and the final tree.
 
address@hidden sxml xpath
address@hidden (sxml xpath)
address@hidden text-handler
address@hidden is a function of three arguments:
+
address@hidden @var
address@hidden text
+the string
+
address@hidden params
+the current params
+
address@hidden layout
+the current layout
+
address@hidden table
+
address@hidden should return two values, the layout to pass to the
+next node and the value to which the string should transform.
+
address@hidden table
address@hidden deffn
+
address@hidden SXPath
address@hidden SXPath
 @subsubsection Overview
 @heading SXPath: SXML Query Language
 SXPath is a query language for SXML, an instance of XML Information set
-(Infoset) in the form of s-expressions. See @code{(sxml ssax)} for the
-definition of SXML and more details. SXPath is also a translation into
+(Infoset) in the form of s-expressions.  See @code{(sxml ssax)} for the
+definition of SXML and more details.  SXPath is also a translation into
 Scheme of an XML Path Language, @uref{http://www.w3.org/TR/xpath,XPath}.
 XPath and SXPath describe means of selecting a set of Infoset's items or
 their properties.
 
 To facilitate queries, XPath maps the XML Infoset into an explicit tree,
 and introduces important notions of a location path and a current,
-context node. A location path denotes a selection of a set of nodes
-relative to a context node. Any XPath tree has a distinguished, root
+context node.  A location path denotes a selection of a set of nodes
+relative to a context node.  Any XPath tree has a distinguished, root
 node -- which serves as the context node for absolute location paths.
 Location path is recursively defined as a location step joined with a
-location path. A location step is a simple query of the database
-relative to a context node. A step may include expressions that further
-filter the selected set. Each node in the resulting set is used as a
-context node for the adjoining location path. The result of the step is
+location path.  A location step is a simple query of the database
+relative to a context node.  A step may include expressions that further
+filter the selected set.  Each node in the resulting set is used as a
+context node for the adjoining location path.  The result of the step is
 a union of the sets returned by the latter location paths.
 
 The SXML representation of the XML Infoset (see SSAX.scm) is rather
-suitable for querying as it is. Bowing to the XPath specification, we
+suitable for querying as it is.  Bowing to the XPath specification, we
 will refer to SXML information items as 'Nodes':
 
 @example 
@@ -610,124 +696,217 @@ An (ordered) set of nodes is just a list of the 
constituent nodes:
        <Nodeset> ::= (<Node> ...)
 @end example
 
-Nodesets, and Nodes other than text strings are both lists. A <Nodeset>
-however is either an empty list, or a list whose head is not a symbol. A
+Nodesets, and Nodes other than text strings are both lists.  A <Nodeset>
+however is either an empty list, or a list whose head is not a symbol.  A
 symbol at the head of a node is either an XML name (in which case it's a
-tag of an XML element), or an administrative name such as '@@'. This
+tag of an XML element), or an administrative name such as '@@'.  This
 uniform list representation makes processing rather simple and elegant,
-while avoiding confusion. The multi-branch tree structure formed by the
+while avoiding confusion.  The multi-branch tree structure formed by the
 mutually-recursive datatypes <Node> and <Nodeset> lends itself well to
 processing by functional languages.
 
 A location path is in fact a composite query over an XPath tree or its
-branch. A singe step is a combination of a projection, selection or a
-transitive closure. Multiple steps are combined via join and union
-operations. This insight allows us to @emph{elegantly} implement XPath
+branch.  A singe step is a combination of a projection, selection or a
+transitive closure.  Multiple steps are combined via join and union
+operations.  This insight allows us to @emph{elegantly} implement XPath
 as a sequence of projection and filtering primitives -- converters --
-joined by @dfn{combinators}. Each converter takes a node and returns a
+joined by @dfn{combinators}.  Each converter takes a node and returns a
 nodeset which is the result of the corresponding query relative to that
-node. A converter can also be called on a set of nodes. In that case it
+node.  A converter can also be called on a set of nodes.  In that case it
 returns a union of the corresponding queries over each node in the set.
 The union is easily implemented as a list append operation as all nodes
-in a SXML tree are considered distinct, by XPath conventions. We also
-preserve the order of the members in the union. Query combinators are
+in a SXML tree are considered distinct, by XPath conventions.  We also
+preserve the order of the members in the union.  Query combinators are
 high-order functions: they take converter(s) (which is a Node|Nodeset ->
-Nodeset function) and compose or otherwise combine them. We will be
+Nodeset function) and compose or otherwise combine them.  We will be
 concerned with only relative location paths [XPath]: an absolute
 location path is a relative path applied to the root node.
 
 Similarly to XPath, SXPath defines full and abbreviated notations for
-location paths. In both cases, the abbreviated notation can be
-mechanically expanded into the full form by simple rewriting rules. In
+location paths.  In both cases, the abbreviated notation can be
+mechanically expanded into the full form by simple rewriting rules.  In
 case of SXPath the corresponding rules are given as comments to a sxpath
-function, below. The regression test suite at the end of this file shows
+function, below.  The regression test suite at the end of this file shows
 a representative sample of SXPaths in both notations, juxtaposed with
-the corresponding XPath expressions. Most of the samples are borrowed
+the corresponding XPath expressions.  Most of the samples are borrowed
 literally from the XPath specification, while the others are adjusted
 for our running example, tree1.
 
 @subsubsection Usage
address@hidden xpath address@hidden nodeset? x
address@hidden defun
address@hidden {Scheme Procedure} nodeset? x
address@hidden deffn
 
address@hidden xpath address@hidden node-typeof? crit
address@hidden defun
address@hidden {Scheme Procedure} node-typeof? crit
address@hidden deffn
 
address@hidden xpath address@hidden node-eq? other
address@hidden defun
address@hidden {Scheme Procedure} node-eq? other
address@hidden deffn
 
address@hidden xpath address@hidden node-equal? other
address@hidden defun
address@hidden {Scheme Procedure} node-equal? other
address@hidden deffn
 
address@hidden xpath address@hidden node-pos n
address@hidden defun
address@hidden {Scheme Procedure} node-pos n
address@hidden deffn
 
address@hidden xpath address@hidden filter pred?
address@hidden {Scheme Procedure} filter pred?
 @verbatim 
  -- Scheme Procedure: filter pred list
      Return all the elements of 2nd arg LIST that satisfy predicate
      PRED.  The list is not disordered - elements that appear in the
      result list occur in the same order as they occur in the argument
-     list. The returned list may share a common tail with the argument
-     list. The dynamic order in which the various applications of pred
+     list.  The returned list may share a common tail with the argument
+     list.  The dynamic order in which the various applications of pred
      are made is not specified.
 
           (filter even? '(0 7 8 8 43 -4)) => (0 8 8 -4)
 
  
 @end verbatim
address@hidden deffn
 
address@hidden defun
-
address@hidden xpath address@hidden take-until pred?
address@hidden defun
address@hidden {Scheme Procedure} take-until pred?
address@hidden deffn
 
address@hidden xpath address@hidden take-after pred?
address@hidden defun
address@hidden {Scheme Procedure} take-after pred?
address@hidden deffn
 
address@hidden xpath address@hidden map-union proc lst
address@hidden defun
address@hidden {Scheme Procedure} map-union proc lst
address@hidden deffn
 
address@hidden xpath address@hidden node-reverse node-or-nodeset
address@hidden defun
address@hidden {Scheme Procedure} node-reverse node-or-nodeset
address@hidden deffn
 
address@hidden xpath address@hidden node-trace title
address@hidden defun
address@hidden {Scheme Procedure} node-trace title
address@hidden deffn
 
address@hidden xpath address@hidden select-kids test-pred?
address@hidden defun
address@hidden {Scheme Procedure} select-kids test-pred?
address@hidden deffn
 
address@hidden xpath address@hidden node-self pred?
address@hidden {Scheme Procedure} node-self pred?
 @verbatim 
  -- Scheme Procedure: filter pred list
      Return all the elements of 2nd arg LIST that satisfy predicate
      PRED.  The list is not disordered - elements that appear in the
      result list occur in the same order as they occur in the argument
-     list. The returned list may share a common tail with the argument
-     list. The dynamic order in which the various applications of pred
+     list.  The returned list may share a common tail with the argument
+     list.  The dynamic order in which the various applications of pred
      are made is not specified.
 
           (filter even? '(0 7 8 8 43 -4)) => (0 8 8 -4)
 
  
 @end verbatim
address@hidden deffn
 
address@hidden defun
address@hidden {Scheme Procedure} node-join . selectors
address@hidden deffn
 
address@hidden xpath address@hidden node-join . selectors
address@hidden defun
address@hidden {Scheme Procedure} node-reduce . converters
address@hidden deffn
 
address@hidden xpath address@hidden node-reduce . converters
address@hidden defun
address@hidden {Scheme Procedure} node-or . converters
address@hidden deffn
 
address@hidden xpath address@hidden node-or . converters
address@hidden defun
address@hidden {Scheme Procedure} node-closure test-pred?
address@hidden deffn
 
address@hidden xpath address@hidden node-closure test-pred?
address@hidden defun
address@hidden {Scheme Procedure} node-parent rootnode
address@hidden deffn
 
address@hidden xpath address@hidden node-parent rootnode
address@hidden defun
address@hidden {Scheme Procedure} sxpath path
address@hidden deffn
+
address@hidden sxml ssax input-parse
address@hidden (sxml ssax input-parse)
address@hidden Overview
+A simple lexer.
+
+The procedures in this module surprisingly often suffice to parse an
+input stream.  They either skip, or build and return tokens, according to
+inclusion or delimiting semantics.  The list of characters to expect,
+include, or to break at may vary from one invocation of a function to
+another.  This allows the functions to easily parse even
+context-sensitive languages.
+
+EOF is generally frowned on, and thrown up upon if encountered.
+Exceptions are mentioned specifically.  The list of expected characters
+(characters to skip until, or break-characters) may include an EOF
+"character", which is to be coded as the symbol, @code{*eof*}.
+
+The input stream to parse is specified as a @dfn{port}, which is usually
+the last (and optional) argument.  It defaults to the current input port
+if omitted.
+
+If the parser encounters an error, it will throw an exception to the key
address@hidden  The arguments will be of the form @code{(@var{port}
address@hidden @var{specialising-msg}*)}.
+
+The first argument is a port, which typically points to the offending
+character or its neighborhood.  You can then use @code{port-column} and
address@hidden to query the current position.  @var{message} is the
+description of the error.  Other arguments supply more details about the
+problem.
+
address@hidden Usage
address@hidden {Scheme Procedure} peek-next-char [port]
address@hidden deffn
+
address@hidden {Scheme Procedure} assert-curr-char expected-chars comment [port]
address@hidden deffn
+
address@hidden {Scheme Procedure} skip-until arg [port]
address@hidden deffn
+
address@hidden {Scheme Procedure} skip-while skip-chars [port]
address@hidden deffn
+
address@hidden {Scheme Procedure} next-token prefix-skipped-chars break-chars 
[comment] [port]
address@hidden deffn
+
address@hidden {Scheme Procedure} next-token-of incl-list/pred [port]
address@hidden deffn
+
address@hidden {Scheme Procedure} read-text-line [port]
address@hidden deffn
+
address@hidden {Scheme Procedure} read-string n [port]
address@hidden deffn
+
address@hidden {Scheme Procedure} find-string-from-port? _ _ . _
+Looks for @var{str} in @var{<input-port>}, optionally within the first
address@hidden characters.
address@hidden deffn
+
address@hidden sxml apply-templates
address@hidden (sxml apply-templates)
address@hidden Overview
+Pre-order traversal of a tree and creation of a new tree:
+
address@hidden 
+       apply-templates:: tree x <templates> -> <new-tree>
address@hidden smallexample
+
+where
+
address@hidden 
+ <templates> ::= (<template> ...)
+ <template>  ::= (<node-test> <node-test> ... <node-test> . <handler>)
+ <node-test> ::= an argument to node-typeof? above
+ <handler>   ::= <tree> -> <new-tree>
address@hidden smallexample
+
+This procedure does a @emph{normal}, pre-order traversal of an SXML
+tree.  It walks the tree, checking at each node against the list of
+matching templates.
+
+If the match is found (which must be unique, i.e., unambiguous), the
+corresponding handler is invoked and given the current node as an
+argument.  The result from the handler, which must be a @code{<tree>},
+takes place of the current node in the resulting tree.  The name of the
+function is not accidental: it resembles rather closely an
address@hidden function of XSLT.
+
address@hidden Usage
address@hidden {Scheme Procedure} apply-templates tree templates
address@hidden deffn
 
address@hidden xpath address@hidden sxpath path
address@hidden defun
diff --git a/doc/ref/texinfo.texi b/doc/ref/texinfo.texi
index b2947fc..ec06863 100644
--- a/doc/ref/texinfo.texi
+++ b/doc/ref/texinfo.texi
@@ -3,8 +3,12 @@
 @c Copyright (C) 2013 Free Software Foundation, Inc.
 @c See the file guile.texi for copying conditions.
 
address@hidden Texinfo
address@hidden Texinfo
address@hidden Note: Don't use "Texinfo" as the node name here because this 
leads to
address@hidden a clash in the HTML output between texinfo.html (from the 
"texinfo"
address@hidden node) and Texinfo.html on case-insensitive file systems such as
address@hidden HFS+ (MacOS X).
address@hidden Texinfo Processing
address@hidden Texinfo Processing
 
 @menu
 * texinfo::              Parse texinfo files or fragments into @code{stexi}, a 
scheme representation
@@ -152,8 +156,8 @@ interested in @code{replace-titles} and 
@code{filter-empty-elements}.
 @xref{texinfo docbook replace-titles,,replace-titles}, and @ref{texinfo
 docbook filter-empty-elements,,filter-empty-elements}.
 
-Returns a nodeset, as described in @ref{sxml xpath}. That is to say,
-this function returns an untagged list of stexi elements.
+Returns a nodeset; that is to say, an untagged list of stexi elements.
address@hidden, for the definition of a nodeset.
 
 @end defun
 
@@ -184,10 +188,12 @@ For example:
 This module implements transformation from @code{stexi} to HTML. Note
 that the output of @code{stexi->shtml} is actually SXML with the HTML
 vocabulary. This means that the output can be further processed, and
-that it must eventually be serialized by @ref{sxml simple
-sxml->xml,sxml->xml}. References (i.e., the @code{@@ref} family of
-commands) are resolved by a @dfn{ref-resolver}. @xref{texinfo html
-add-ref-resolver!,add-ref-resolver!}, for more information.
+that it must eventually be serialized by @code{sxml->xml}.
address@hidden and Writing XML}.
+
+References (i.e., the @code{@@ref} family of commands) are resolved by a
address@hidden  @xref{texinfo html
+add-ref-resolver!,add-ref-resolver!}.
 
 @subsubsection Usage
 @anchor{texinfo html address@hidden add-ref-resolver! proc
diff --git a/doc/ref/web.texi b/doc/ref/web.texi
index 0f69089..0d41f9f 100644
--- a/doc/ref/web.texi
+++ b/doc/ref/web.texi
@@ -10,7 +10,7 @@
 @cindex HTTP
 
 It has always been possible to connect computers together and share
-information between them, but the rise of the World-Wide Web over the
+information between them, but the rise of the World Wide Web over the
 last couple of decades has made it much easier to do so.  The result is
 a richly connected network of computation, in which Guile forms a part.
 
@@ -127,8 +127,8 @@ basic idea is that HTML is either text, represented by a 
string, or an
 element, represented as a tagged list.  So @samp{foo} becomes
 @samp{"foo"}, and @samp{<b>foo</b>} becomes @samp{(b "foo")}.
 Attributes, if present, go in a tagged list headed by @samp{@@}, like
address@hidden(img (@@ (src "http://example.com/foo.png";)))}.  @xref{sxml
-simple}, for more information.
address@hidden(img (@@ (src "http://example.com/foo.png";)))}.  @xref{SXML}, for
+more information.
 
 The good thing about SXML is that HTML elements cannot be confused with
 text.  Let's make a new definition of @code{para}:
@@ -206,9 +206,10 @@ The following procedures can be found in the @code{(web 
uri)}
 module. Load it into your Guile, using a form like the above, to have
 access to them.
 
address@hidden {Scheme Procedure} build-uri scheme [#:address@hidden 
[#:address@hidden @
-       [#:address@hidden [#:address@hidden""}] [#:address@hidden @
-       [#:address@hidden [#:address@hidden
address@hidden {Scheme Procedure} build-uri scheme @
+       [#:address@hidden [#:address@hidden [#:address@hidden @
+       [#:address@hidden""}] [#:address@hidden [#:address@hidden @
+       [#:address@hidden
 Construct a URI object.  @var{scheme} should be a symbol, @var{port}
 either a positive, exact integer or @code{#f}, and the rest of the
 fields are either strings or @code{#f}.  If @var{validate?} is true,
@@ -216,7 +217,7 @@ also run some consistency checks to make sure that the 
constructed URI
 is valid.
 @end deffn
 
address@hidden {Scheme Procedure} uri? x
address@hidden {Scheme Procedure} uri? obj
 @deffnx {Scheme Procedure} uri-scheme uri
 @deffnx {Scheme Procedure} uri-userinfo uri
 @deffnx {Scheme Procedure} uri-host uri
@@ -249,9 +250,9 @@ Percent-decode the given @var{str}, according to 
@var{encoding}, which
 should be the name of a character encoding.
 
 Note that this function should not generally be applied to a full URI
-string. For paths, use split-and-decode-uri-path instead. For query
-strings, split the query on @code{&} and @code{=} boundaries, and decode
-the components separately.
+string. For paths, use @code{split-and-decode-uri-path} instead. For
+query strings, split the query on @code{&} and @code{=} boundaries, and
+decode the components separately.
 
 Note also that percent-encoded strings encode @emph{bytes}, not
 characters.  There is no guarantee that a given byte sequence is a valid
@@ -351,8 +352,8 @@ parsing and serialization procedures.  If a header is 
unknown, its
 string name is simply its symbol name in title-case.
 
 @deffn {Scheme Procedure} known-header? sym
-Return @code{#t} iff @var{sym} is a known header, with associated
-parsers and serialization procedures.
+Return @code{#t} if @var{sym} is a known header, with associated
+parsers and serialization procedures, or @code{#f} otherwise.
 @end deffn
 
 @deffn {Scheme Procedure} header-parser sym
@@ -378,7 +379,8 @@ For more on the set of headers that Guile knows about out 
of the box,
 @pxref{HTTP Headers}.  To add your own, use the @code{declare-header!}
 procedure:
 
address@hidden {Scheme Procedure} declare-header! name parser validator writer 
[#:address@hidden
address@hidden {Scheme Procedure} declare-header! name parser validator writer @
+       [#:address@hidden
 Declare a parser, validator, and writer for a given header.
 @end deffn
 
@@ -405,8 +407,8 @@ you want a header's value to be returned/written ``as-is''.
 @end deffn
 
 @deffn {Scheme Procedure} valid-header? sym val
-Return a true value iff @var{val} is a valid Scheme value for the header
-with name @var{sym}.
+Return a true value if @var{val} is a valid Scheme value for the header
+with name @var{sym}, or @code{#f} otherwise.
 @end deffn
 
 Now that we have a generic interface for reading and writing headers, we
@@ -450,7 +452,7 @@ like @code{GET}.
 @end deffn
 
 @deffn {Scheme Procedure} parse-http-version str [start] [end]
-Parse an HTTP version from @var{str}, returning it as a major-minor
+Parse an HTTP version from @var{str}, returning it as a major--minor
 pair. For example, @code{HTTP/1.1} parses as the pair of integers,
 @code{(1 . 1)}.
 @end deffn
@@ -471,7 +473,7 @@ Write the first line of an HTTP request to @var{port}.
 
 @deffn {Scheme Procedure} read-response-line port
 Read the first line of an HTTP response from @var{port}, returning three
-values: the HTTP version, the response code, and the "reason phrase".
+values: the HTTP version, the response code, and the ``reason phrase''.
 @end deffn
 
 @deffn {Scheme Procedure} write-response-line version code reason-phrase port
@@ -1130,13 +1132,13 @@ any loss of generality.
 
 @subsubsection Request API
 
address@hidden {Scheme Procedure} request? 
address@hidden {Scheme Procedure} request-method 
address@hidden {Scheme Procedure} request-uri 
address@hidden {Scheme Procedure} request-version 
address@hidden {Scheme Procedure} request-headers 
address@hidden {Scheme Procedure} request-meta 
address@hidden {Scheme Procedure} request-port 
address@hidden {Scheme Procedure} request? obj 
address@hidden {Scheme Procedure} request-method request
address@hidden {Scheme Procedure} request-uri request
address@hidden {Scheme Procedure} request-version request
address@hidden {Scheme Procedure} request-headers request
address@hidden {Scheme Procedure} request-meta request
address@hidden {Scheme Procedure} request-port request
 A predicate and field accessors for the request type.  The fields are as
 follows:
 @table @code
@@ -1170,7 +1172,9 @@ request, you may read the body separately, and likewise 
for writing
 requests.
 @end deffn
 
address@hidden {Scheme Procedure} build-request uri [#:method='GET] 
[#:version='(1 . 1)] [#:headers='()] [#:port=#f] [#:meta='()] 
[#:validate-headers?=#t]
address@hidden {Scheme Procedure} build-request uri [#:method='GET] @
+       [#:version='(1 . 1)] [#:headers='()] [#:port=#f] [#:meta='()] @
+       [#:validate-headers?=#t]
 Construct an HTTP request object. If @var{validate-headers?} is true,
 the headers are each run through their respective validators.
 @end deffn
@@ -1253,12 +1257,12 @@ A helper routine to determine the absolute URI of a 
request, using the
 As with requests (@pxref{Requests}), Guile offers a data type for HTTP
 responses.  Again, the body is represented separately from the request.
 
address@hidden {Scheme Procedure} response? 
address@hidden {Scheme Procedure} response-version 
address@hidden {Scheme Procedure} response-code 
address@hidden {Scheme Procedure} response? obj
address@hidden {Scheme Procedure} response-version response
address@hidden {Scheme Procedure} response-code response
 @deffnx {Scheme Procedure} response-reason-phrase response
address@hidden {Scheme Procedure} response-headers 
address@hidden {Scheme Procedure} response-port 
address@hidden {Scheme Procedure} response-headers response
address@hidden {Scheme Procedure} response-port response
 A predicate and field accessors for the response type.  The fields are as
 follows:
 @table @code
@@ -1384,6 +1388,10 @@ Return @code{#t} if @var{type}, a symbol as returned by
 @code{(web client)} provides a simple, synchronous HTTP client, built on
 the lower-level HTTP, request, and response modules.
 
address@hidden
+(use-modules (web client))
address@hidden example
+
 @deffn {Scheme Procedure} open-socket-for-uri uri
 Return an open input/output port for a connection to URI.
 @end deffn
@@ -1419,9 +1427,9 @@ If you already have a port open, pass it as @var{port}.  
Otherwise, a
 connection will be opened to the server corresponding to @var{uri}.  Any
 extra headers in the alist @var{headers} will be added to the request.
 
-If @var{body} is not #f, a message body will also be sent with the HTTP
-request.  If @var{body} is a string, it is encoded according to the
-content-type in @var{headers}, defaulting to UTF-8.  Otherwise
+If @var{body} is not @code{#f}, a message body will also be sent with
+the HTTP request.  If @var{body} is a string, it is encoded according to
+the content-type in @var{headers}, defaulting to UTF-8.  Otherwise
 @var{body} should be a bytevector, or @code{#f} for no body.  Although a
 message body may be sent with any request, usually only @code{POST} and
 @code{PUT} requests have bodies.
@@ -1480,8 +1488,8 @@ The life cycle of a server goes as follows:
 
 @enumerate
 @item
-The @code{open} hook is called, to open the server. @code{open} takes 0 or
-more arguments, depending on the backend, and returns an opaque
+The @code{open} hook is called, to open the server. @code{open} takes
+zero or more arguments, depending on the backend, and returns an opaque
 server socket object, or signals an error.
 
 @item
@@ -1578,8 +1586,8 @@ in, allowing the user's handler to explicitly manage its 
state.
 @end deffn
 
 @deffn {Scheme Procedure} sanitize-response request response body
-"Sanitize" the given response and body, making them appropriate for the
-given request.
+``Sanitize'' the given response and body, making them appropriate for
+the given request.
 
 As a convenience to web handler authors, @var{response} may be given as
 an alist of headers, in which case it is used to construct a default
@@ -1615,7 +1623,9 @@ and body, and write the response to the client.  Return 
the new state
 produced by the handler procedure.
 @end deffn
 
address@hidden {Scheme Procedure} run-server handler [impl='http] 
[open-params='()] . state
address@hidden {Scheme Procedure} run-server handler @
+                          [impl='http] [open-params='()] @
+                          arg @dots{}
 Run Guile's built-in web server.
 
 @var{handler} should be a procedure that takes two or more arguments,
@@ -1627,16 +1637,20 @@ For examples, skip ahead to the next section, @ref{Web 
Examples}.
 The response and body will be run through @code{sanitize-response}
 before sending back to the client.
 
-Additional arguments to @var{handler} are taken from @var{state}.
-Additional return values are accumulated into a new @var{state}, which
-will be used for subsequent requests.  In this way a handler can
-explicitly manage its state.
+Additional arguments to @var{handler} are taken from @var{arg}
address@hidden  These arguments comprise a @dfn{state}.  Additional return
+values are accumulated into a new state, which will be used for
+subsequent requests.  In this way a handler can explicitly manage its
+state.
 @end deffn
 
 The default web server implementation is @code{http}, which binds to a
 socket, listening for request on that port.
 
address@hidden {HTTP Implementation} http [#:host=#f] [#:family=AF_INET] 
[#:addr=INADDR_LOOPBACK] [#:port 8080] [#:socket]
address@hidden {HTTP Implementation} http [#:host=#f] @
+                             [#:family=AF_INET] @
+                             [#:addr=INADDR_LOOPBACK] @
+                             [#:port 8080] [#:socket]
 The default HTTP implementation.  We document it as a function with
 keyword arguments, because that is precisely the way that it is -- all
 of the @var{open-params} to @code{run-server} get passed to the
@@ -1769,7 +1783,7 @@ message body is long enough.)
 The web handler interface is a common baseline that all kinds of Guile
 web applications can use.  You will usually want to build something on
 top of it, however, especially when producing HTML.  Here is a simple
-example that builds up HTML output using SXML (@pxref{sxml simple}).
+example that builds up HTML output using SXML (@pxref{SXML}).
 
 First, load up the modules:
 
diff --git a/doc/release.org b/doc/release.org
index 95ba12e..875ec27 100644
--- a/doc/release.org
+++ b/doc/release.org
@@ -1,5 +1,6 @@
 #+TITLE: Release Process for GNU Guile 2.0
 #+AUTHOR: Ludovic Courtès
+#+STARTUP: content
 #+EMAIL: address@hidden
 
 This document describes the typical release process for Guile 2.0.
@@ -53,7 +54,6 @@ If you're still in a good mood, you may also want to check on 
porter
 boxes for other OSes.  The GNU/Hurd people have 
[[http://www.gnu.org/software/hurd/public_hurd_boxen.html][porter boxes]], and 
so do
 the [[http://www.opencsw.org/standards/build_farm][OpenCSW Solaris Team]] and 
the 
[[http://lists.gnu.org/archive/html/autoconf/2012-11/msg00039.html][Snakebite]] 
project.
 
-
 *** Post a pre-release announcement to address@hidden'
 
 Send a link to 
[[http://hydra.nixos.org/job/gnu/guile-2-0/tarball/latest/download-by-type/file/source-dist][the
 latest tarball]].  This will allow readers to test on
@@ -87,15 +87,14 @@ The tag *must* be `v2.0.X'.  For the sake of consistency, 
always use
 
 Normally nobody committed in the meantime.  ;-)
 
-** Run "make dist"
+** Run "make distcheck"
 
 This should trigger an `autoreconf', as `build-aux/git-version-gen'
-notices the new tag.  After "make dist", double-check that `./configure
---version' reports the new version number.
+notices the new tag.  Make sure you have configured with all options
+enabled (Readline, --enable-deprecated, etc.)
 
-The reason for running "make dist" instead of "make distcheck" is that
-it's much faster and any distribution issues should have been caught by
-Hydra already.
+After "make distcheck", double-check that `./configure --version'
+reports the new version number.
 
 ** Upload
 
@@ -146,7 +145,7 @@ Use `build-aux/gendocs', add to the manual/ directory of 
the web site.
   $ build-aux/announce-gen --release-type=stable --package-name=guile \
       --previous-version=2.0.1 --current-version=2.0.2 \
       --gpg-key-id=MY-KEY --url-directory=ftp://ftp.gnu.org/gnu/guile \
-      --bootstrap-tools=autoconf,automake,libtool,gnulib \
+      --bootstrap-tools=autoconf,automake,libtool,gnulib,makeinfo \
       --gnulib-version=$( cd ~/src/gnulib ; git describe )
 
 The subject must be "GNU Guile 2.0.X released".  The text should remain
@@ -174,7 +173,7 @@ more informal, with a link to the email announcement for 
details.
 
 
 
-Copyright © 2011, 2012 Free Software Foundation, Inc.
+Copyright © 2011, 2012, 2013 Free Software Foundation, Inc.
 
   Copying and distribution of this file, with or without modification,
   are permitted in any medium without royalty provided the copyright
diff --git a/gnulib-local/build-aux/git-version-gen.diff 
b/gnulib-local/build-aux/git-version-gen.diff
index c222a99..f875f49 100644
--- a/gnulib-local/build-aux/git-version-gen.diff
+++ b/gnulib-local/build-aux/git-version-gen.diff
@@ -2,47 +2,33 @@ This patch is being discussed
 at <http://lists.gnu.org/archive/html/bug-gnulib/2012-07/msg00079.html>.
 Remove when integrated in Gnulib.
 
---- a/build-aux/git-version-gen        2012-06-12 21:25:48.000000000 +0200
-+++ b/build-aux/git-version-gen        2012-07-07 01:52:08.000000000 +0200
-@@ -1,6 +1,6 @@
- #!/bin/sh
- # Print a version string.
--scriptversion=2012-03-18.17; # UTC
-+scriptversion=2012-07-06.14; # UTC
- 
- # Copyright (C) 2007-2012 Free Software Foundation, Inc.
- #
-@@ -85,20 +85,25 @@
- 
+--- a/build-aux/git-version-gen
++++ b/build-aux/git-version-gen
+@@ -86,6 +86,7 @@ Print a version string.
  Options:
  
--   --prefix           prefix of git tags (default 'v')
-+   --prefix     prefix of git tags to strip from version (default 'v')
-+   --match      pattern for git tags to match (default: '\$prefix*')
- 
--   --help             display this help and exit
--   --version          output version information and exit
-+   --help       display this help and exit
-+   --version    output version information and exit
- 
--Running without arguments will suffice in most cases."
-+Running without arguments will suffice in most cases.  If no --match
-+argument is given, only match tags that begin with the --prefix."
+    --prefix           prefix of git tags (default 'v')
++   --match            pattern for git tags to match (default: '\$prefix*')
+    --fallback         fallback version to use if \"git --version\" fails
  
+    --help             display this help and exit
+@@ -96,11 +97,15 @@ Running without arguments will suffice in most cases."
  prefix=v
+ fallback=
+ 
 +unset match
 +unset tag_sed_script
- 
++
  while test $# -gt 0; do
    case $1 in
      --help) echo "$usage"; exit 0;;
      --version) echo "$version"; exit 0;;
      --prefix) shift; prefix="$1";;
 +    --match) shift; match="$1";;
+     --fallback) shift; fallback="$1";;
      -*)
        echo "$0: Unknown option '$1'." >&2
-       echo "$0: Try '--help' for more information." >&2
-@@ -121,6 +126,7 @@
+@@ -124,6 +129,7 @@ if test "x$tarball_version_file" = x; then
      exit 1
  fi
  
@@ -50,13 +36,12 @@ Remove when integrated in Gnulib.
  tag_sed_script="${tag_sed_script:-s/x/x/}"
  
  nl='
-@@ -151,8 +157,7 @@
+@@ -154,7 +160,7 @@ then
  # directory, and "git describe" output looks sensible, use that to
  # derive a version string.
  elif test "`git log -1 --pretty=format:x . 2>&1`" = x \
 -    && v=`git describe --abbrev=4 --match="$prefix*" HEAD 2>/dev/null \
--          || git describe --abbrev=4 HEAD 2>/dev/null` \
-+    && v=`git describe --abbrev=4 --match="$match" HEAD 2>/dev/null` \
++    && v=`git describe --abbrev=4 --match="$match" HEAD 2>/dev/null \
+           || git describe --abbrev=4 HEAD 2>/dev/null` \
      && v=`printf '%s\n' "$v" | sed "$tag_sed_script"` \
      && case $v in
-          $prefix[0-9]*) ;;
diff --git a/guile-readline/readline.c b/guile-readline/readline.c
index 1e697eb..aac6e18 100644
--- a/guile-readline/readline.c
+++ b/guile-readline/readline.c
@@ -1,6 +1,7 @@
 /* readline.c --- line editing support for Guile */
 
-/* Copyright (C) 1997,1999,2000,2001, 2002, 2003, 2006, 2007, 2008, 2009, 
2010, 2013 Free Software Foundation, Inc.
+/* Copyright (C) 1997,1999,2000,2001, 2002, 2003, 2006, 2007, 2008,
+ *   2009, 2010, 2013 Free Software Foundation, Inc.
  * 
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -27,19 +28,13 @@
 
 #ifdef HAVE_RL_GETC_FUNCTION
 #include "libguile.h"
-#include "libguile/iselect.h"
 
 #include <stdio.h>
-#ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#endif
 #include <readline/readline.h>
 #include <readline/history.h>
-#ifndef __MINGW32__
 #include <sys/time.h>
-#else
-#include <io.h>
-#endif
+#include <sys/select.h>
 #include <signal.h>
 
 #include "libguile/validate.h"
@@ -207,10 +202,8 @@ SCM_DEFINE (scm_readline, "%readline", 0, 4, 0,
 
   scm_dynwind_end ();
 
-#ifndef __MINGW32__
   fclose (rl_instream);
   fclose (rl_outstream);
-#endif
 
   --in_readline;
   return ans;
@@ -240,10 +233,8 @@ unwind_readline (void *unused)
   rl_free_line_state ();
   rl_cleanup_after_signal ();
   fputc ('\n', rl_outstream); /* We don't want next output on this line */
-#ifndef __MINGW32__
   fclose (rl_instream);
   fclose (rl_outstream);
-#endif
   --in_readline;
 }
 
@@ -314,10 +305,8 @@ scm_readline_init_ports (SCM inp, SCM outp)
 
   input_port = inp;
   output_port = outp;
-#ifndef __MINGW32__
   rl_instream = stream_from_fport (inp, "r", s_scm_readline);
   rl_outstream = stream_from_fport (outp, "w", s_scm_readline);
-#endif
 }
 
 
@@ -489,11 +478,9 @@ static int
 match_paren (int x, int k)
 {
   int tmp;
-#ifndef __MINGW32__
   int fno;
-  SELECT_TYPE readset;
+  fd_set readset;
   struct timeval timeout;
-#endif
 
   rl_insert (x, k);
   if (!SCM_READLINE_BOUNCE_PARENS)
@@ -504,14 +491,12 @@ match_paren (int x, int k)
       && rl_line_buffer[rl_point - 2] == '\\')
     return 0;
 
-#ifndef __MINGW32__
   tmp = 1000 * SCM_READLINE_BOUNCE_PARENS;
   timeout.tv_sec = tmp / 1000000;
   timeout.tv_usec = tmp % 1000000;
   FD_ZERO (&readset);
   fno = fileno (rl_instream);
   FD_SET (fno, &readset);
-#endif
 
   if (rl_point > 1)
     {
@@ -520,12 +505,7 @@ match_paren (int x, int k)
       if (rl_point > -1)
        {
          rl_redisplay ();
-#ifndef __MINGW32__
-         scm_std_select (fno + 1, &readset, NULL, NULL, &timeout);
-#else
-         WaitForSingleObject (GetStdHandle(STD_INPUT_HANDLE),
-                              SCM_READLINE_BOUNCE_PARENS); 
-#endif
+         select (fno + 1, &readset, NULL, NULL, &timeout);
        }
       rl_point = tmp;
     }
@@ -542,9 +522,7 @@ scm_init_readline ()
 #include "guile-readline/readline.x"
   scm_readline_completion_function_var
     = scm_c_define ("*readline-completion-function*", SCM_BOOL_F);
-#ifndef __MINGW32__
   rl_getc_function = current_input_getc;
-#endif
 #if defined (_RL_FUNCTION_TYPEDEF)
   rl_completion_entry_function = (rl_compentry_func_t*) completion_function;
 #else  
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 49c5140..8857a90 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -1,6 +1,6 @@
 ## DO NOT EDIT! GENERATED AUTOMATICALLY!
 ## Process this file with automake to produce Makefile.in.
-# Copyright (C) 2002-2012 Free Software Foundation, Inc.
+# Copyright (C) 2002-2013 Free Software Foundation, Inc.
 #
 # 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
@@ -21,7 +21,7 @@
 # the same distribution terms as the rest of that program.
 #
 # Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --local-dir=gnulib-local 
--lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests 
--aux-dir=build-aux --lgpl=3 --no-conditional-dependencies --libtool 
--macro-prefix=gl --no-vc-files accept alignof alloca-opt announce-gen 
autobuild bind byteswap canonicalize-lgpl ceil clock-time close connect dirfd 
duplocale environ extensions flock floor fpieee frexp full-read full-write func 
gendocs getaddrinfo getpeername getsockname getsockopt git-version-gen 
gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf 
inet_ntop inet_pton isinf isnan ldexp lib-symbol-versions lib-symbol-visibility 
libunistring listen localcharset locale log1p maintainer-makefile malloc-gnu 
malloca nl_langinfo nproc open pipe2 putenv recv recvfrom regex rename send 
sendto setenv setsockopt shutdown socket stat-time stdlib strftime striconveh 
string sys_stat trunc verify vsnprintf warnings wchar
+# Reproduce by: gnulib-tool --import --dir=. --local-dir=gnulib-local 
--lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests 
--aux-dir=build-aux --lgpl=3 --no-conditional-dependencies --libtool 
--macro-prefix=gl --no-vc-files accept alignof alloca-opt announce-gen 
autobuild bind byteswap c-strcase canonicalize-lgpl ceil clock-time close 
connect dirfd duplocale environ extensions flock floor fpieee frexp fstat 
full-read full-write func gendocs getaddrinfo getlogin getpeername getsockname 
getsockopt git-version-gen gitlog-to-changelog gnu-web-doc-update gnupload 
havelib iconv_open-utf inet_ntop inet_pton isinf isnan ldexp 
lib-symbol-versions lib-symbol-visibility libunistring listen localcharset 
locale log1p maintainer-makefile malloc-gnu malloca nl_langinfo nproc open 
pipe-posix pipe2 poll putenv recv recvfrom regex rename select send sendto 
setenv setsockopt shutdown socket stat-time stdlib strftime striconveh string 
sys_stat time times trunc verify vsnprintf warnings wchar
 
 AUTOMAKE_OPTIONS = 1.5 gnits subdir-objects
 
@@ -62,6 +62,8 @@ libgnu_la_LDFLAGS += $(ISNANL_LIBM)
 libgnu_la_LDFLAGS += $(LDEXP_LIBM)
 libgnu_la_LDFLAGS += $(LIBSOCKET)
 libgnu_la_LDFLAGS += $(LIB_CLOCK_GETTIME)
+libgnu_la_LDFLAGS += $(LIB_POLL)
+libgnu_la_LDFLAGS += $(LIB_SELECT)
 libgnu_la_LDFLAGS += $(LOG1P_LIBM)
 libgnu_la_LDFLAGS += $(LOG_LIBM)
 libgnu_la_LDFLAGS += $(LTLIBICONV)
@@ -87,6 +89,17 @@ EXTRA_DIST += alignof.h
 
 ## end   gnulib module alignof
 
+## begin gnulib module alloca
+
+
+libgnu_la_LIBADD += @LTALLOCA@
+libgnu_la_DEPENDENCIES += @LTALLOCA@
+EXTRA_DIST += alloca.c
+
+EXTRA_libgnu_la_SOURCES += alloca.c
+
+## end   gnulib module alloca
+
 ## begin gnulib module alloca-opt
 
 BUILT_SOURCES += $(ALLOCA_H)
@@ -371,6 +384,15 @@ EXTRA_DIST += dosname.h
 
 ## end   gnulib module dosname
 
+## begin gnulib module dup2
+
+
+EXTRA_DIST += dup2.c
+
+EXTRA_libgnu_la_SOURCES += dup2.c
+
+## end   gnulib module dup2
+
 ## begin gnulib module duplocale
 
 
@@ -556,6 +578,15 @@ EXTRA_libgnu_la_SOURCES += gai_strerror.c getaddrinfo.c
 
 ## end   gnulib module getaddrinfo
 
+## begin gnulib module getlogin
+
+
+EXTRA_DIST += getlogin.c
+
+EXTRA_libgnu_la_SOURCES += getlogin.c
+
+## end   gnulib module getlogin
+
 ## begin gnulib module getpeername
 
 
@@ -1006,6 +1037,7 @@ EXTRA_DIST += malloca.h malloca.valgrind
 ## begin gnulib module math
 
 BUILT_SOURCES += math.h
+libgnu_la_SOURCES += math.c
 
 # We need the following in order to create <math.h> when the system
 # doesn't have one that works with the given compiler.
@@ -1438,12 +1470,59 @@ EXTRA_DIST += pathmax.h
 
 ## end   gnulib module pathmax
 
+## begin gnulib module pipe-posix
+
+
+EXTRA_DIST += pipe.c
+
+EXTRA_libgnu_la_SOURCES += pipe.c
+
+## end   gnulib module pipe-posix
+
 ## begin gnulib module pipe2
 
 libgnu_la_SOURCES += pipe2.c
 
 ## end   gnulib module pipe2
 
+## begin gnulib module poll
+
+
+EXTRA_DIST += poll.c
+
+EXTRA_libgnu_la_SOURCES += poll.c
+
+## end   gnulib module poll
+
+## begin gnulib module poll-h
+
+BUILT_SOURCES += poll.h
+
+# We need the following in order to create <poll.h> when the system
+# doesn't have one.
+poll.h: poll.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_USE_H)
+       $(AM_V_GEN)rm -f address@hidden $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+             -e 's|@''HAVE_POLL_H''@|$(HAVE_POLL_H)|g' \
+             -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_POLL_H''@|$(NEXT_POLL_H)|g' \
+             -e 's/@''GNULIB_POLL''@/$(GNULIB_POLL)/g' \
+             -e 's|@''HAVE_POLL''@|$(HAVE_POLL)|g' \
+             -e 's|@''REPLACE_POLL''@|$(REPLACE_POLL)|g' \
+             -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+             -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+             < $(srcdir)/poll.in.h; \
+       } > address@hidden && \
+       mv -f address@hidden $@
+MOSTLYCLEANFILES += poll.h poll.h-t
+
+EXTRA_DIST += poll.in.h
+
+## end   gnulib module poll-h
+
 ## begin gnulib module putenv
 
 
@@ -1559,6 +1638,15 @@ EXTRA_DIST += same-inode.h
 
 ## end   gnulib module same-inode
 
+## begin gnulib module select
+
+
+EXTRA_DIST += select.c
+
+EXTRA_libgnu_la_SOURCES += select.c
+
+## end   gnulib module select
+
 ## begin gnulib module send
 
 
@@ -2093,6 +2181,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) \
              -e 's/@''GNULIB_REALLOC_POSIX''@/$(GNULIB_REALLOC_POSIX)/g' \
              -e 's/@''GNULIB_REALPATH''@/$(GNULIB_REALPATH)/g' \
              -e 's/@''GNULIB_RPMATCH''@/$(GNULIB_RPMATCH)/g' \
+             -e 's/@''GNULIB_SECURE_GETENV''@/$(GNULIB_SECURE_GETENV)/g' \
              -e 's/@''GNULIB_SETENV''@/$(GNULIB_SETENV)/g' \
              -e 's/@''GNULIB_STRTOD''@/$(GNULIB_STRTOD)/g' \
              -e 's/@''GNULIB_STRTOLL''@/$(GNULIB_STRTOLL)/g' \
@@ -2121,6 +2210,7 @@ stdlib.h: stdlib.in.h $(top_builddir)/config.status 
$(CXXDEFS_H) \
              -e 's|@''HAVE_RANDOM_R''@|$(HAVE_RANDOM_R)|g' \
              -e 's|@''HAVE_REALPATH''@|$(HAVE_REALPATH)|g' \
              -e 's|@''HAVE_RPMATCH''@|$(HAVE_RPMATCH)|g' \
+             -e 's|@''HAVE_SECURE_GETENV''@|$(HAVE_SECURE_GETENV)|g' \
              -e 's|@''HAVE_DECL_SETENV''@|$(HAVE_DECL_SETENV)|g' \
              -e 's|@''HAVE_STRTOD''@|$(HAVE_STRTOD)|g' \
              -e 's|@''HAVE_STRTOLL''@|$(HAVE_STRTOLL)|g' \
@@ -2311,9 +2401,44 @@ EXTRA_DIST += sys_file.in.h
 
 ## end   gnulib module sys_file
 
+## begin gnulib module sys_select
+
+BUILT_SOURCES += sys/select.h
+
+# We need the following in order to create <sys/select.h> when the system
+# doesn't have one that works with the given compiler.
+sys/select.h: sys_select.in.h $(top_builddir)/config.status $(CXXDEFS_H) 
$(WARN_ON_USE_H)
+       $(AM_V_at)$(MKDIR_P) sys
+       $(AM_V_GEN)rm -f address@hidden $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+             -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_SYS_SELECT_H''@|$(NEXT_SYS_SELECT_H)|g' \
+             -e 's|@''HAVE_SYS_SELECT_H''@|$(HAVE_SYS_SELECT_H)|g' \
+             -e 's/@''GNULIB_PSELECT''@/$(GNULIB_PSELECT)/g' \
+             -e 's/@''GNULIB_SELECT''@/$(GNULIB_SELECT)/g' \
+             -e 's|@''HAVE_WINSOCK2_H''@|$(HAVE_WINSOCK2_H)|g' \
+             -e 's|@''HAVE_PSELECT''@|$(HAVE_PSELECT)|g' \
+             -e 's|@''REPLACE_PSELECT''@|$(REPLACE_PSELECT)|g' \
+             -e 's|@''REPLACE_SELECT''@|$(REPLACE_SELECT)|g' \
+             -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
+             -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+             < $(srcdir)/sys_select.in.h; \
+       } > address@hidden && \
+       mv address@hidden $@
+MOSTLYCLEANFILES += sys/select.h sys/select.h-t
+MOSTLYCLEANDIRS += sys
+
+EXTRA_DIST += sys_select.in.h
+
+## end   gnulib module sys_select
+
 ## begin gnulib module sys_socket
 
 BUILT_SOURCES += sys/socket.h
+libgnu_la_SOURCES += sys_socket.c
 
 # We need the following in order to create <sys/socket.h> when the system
 # doesn't have one that works with the given compiler.
@@ -2458,6 +2583,37 @@ EXTRA_DIST += sys_time.in.h
 
 ## end   gnulib module sys_time
 
+## begin gnulib module sys_times
+
+BUILT_SOURCES += sys/times.h
+
+# We need the following in order to create <sys/times.h> when the system
+# doesn't have one that works with the given compiler.
+sys/times.h: sys_times.in.h $(top_builddir)/config.status $(WARN_ON_USE_H) 
$(ARG_NONNULL_H)
+       $(AM_V_at)$(MKDIR_P) sys
+       $(AM_V_GEN)rm -f address@hidden $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's|@''GUARD_PREFIX''@|GL|g' \
+             -e 's/@''HAVE_SYS_TIMES_H''@/$(HAVE_SYS_TIMES_H)/g' \
+             -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_SYS_TIMES_H''@|$(NEXT_SYS_TIMES_H)|g' \
+             -e 's/@''GNULIB_TIMES''@/$(GNULIB_TIMES)/g' \
+             -e 's|@''HAVE_STRUCT_TMS''@|$(HAVE_STRUCT_TMS)|g' \
+             -e 's|@''HAVE_TIMES''@|$(HAVE_TIMES)|g' \
+             -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
+             -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+             < $(srcdir)/sys_times.in.h; \
+       } > address@hidden && \
+       mv address@hidden $@
+MOSTLYCLEANFILES += sys/times.h sys/times.h-t
+MOSTLYCLEANDIRS += sys
+
+EXTRA_DIST += sys_times.in.h
+
+## end   gnulib module sys_times
+
 ## begin gnulib module sys_types
 
 BUILT_SOURCES += sys/types.h
@@ -2560,6 +2716,15 @@ EXTRA_libgnu_la_SOURCES += time_r.c
 
 ## end   gnulib module time_r
 
+## begin gnulib module times
+
+
+EXTRA_DIST += times.c
+
+EXTRA_libgnu_la_SOURCES += times.c
+
+## end   gnulib module times
+
 ## begin gnulib module trunc
 
 
@@ -2572,6 +2737,7 @@ EXTRA_libgnu_la_SOURCES += trunc.c
 ## begin gnulib module unistd
 
 BUILT_SOURCES += unistd.h
+libgnu_la_SOURCES += unistd.c
 
 # We need the following in order to create an empty placeholder for
 # <unistd.h> when the system doesn't have one.
@@ -2963,6 +3129,7 @@ EXTRA_libgnu_la_SOURCES += wcrtomb.c
 ## begin gnulib module wctype-h
 
 BUILT_SOURCES += wctype.h
+libgnu_la_SOURCES += wctype-h.c
 
 # We need the following in order to create <wctype.h> when the system
 # doesn't have one that works with the given compiler.
diff --git a/lib/accept.c b/lib/accept.c
index 78bb822..0c8e52e 100644
--- a/lib/accept.c
+++ b/lib/accept.c
@@ -1,6 +1,6 @@
 /* accept.c --- wrappers for Windows accept function
 
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/alignof.h b/lib/alignof.h
index b6d8666..2bf3820 100644
--- a/lib/alignof.h
+++ b/lib/alignof.h
@@ -1,5 +1,5 @@
 /* Determine alignment of types.
-   Copyright (C) 2003-2004, 2006, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2003-2004, 2006, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/alloca.c b/lib/alloca.c
new file mode 100644
index 0000000..ee0f018
--- /dev/null
+++ b/lib/alloca.c
@@ -0,0 +1,478 @@
+/* alloca.c -- allocate automatically reclaimed memory
+   (Mostly) portable public-domain implementation -- D A Gwyn
+
+   This implementation of the PWB library alloca function,
+   which is used to allocate space off the run-time stack so
+   that it is automatically reclaimed upon procedure exit,
+   was inspired by discussions with J. Q. Johnson of Cornell.
+   J.Otto Tennant <address@hidden> contributed the Cray support.
+
+   There are some preprocessor constants that can
+   be defined when compiling for your specific system, for
+   improved efficiency; however, the defaults should be okay.
+
+   The general concept of this implementation is to keep
+   track of all alloca-allocated blocks, and reclaim any
+   that are found to be deeper in the stack than the current
+   invocation.  This heuristic does not reclaim storage as
+   soon as it becomes invalid, but it will do so eventually.
+
+   As a special case, alloca(0) reclaims storage without
+   allocating any.  It is a good idea to use alloca(0) in
+   your main control loop, etc. to force garbage collection.  */
+
+#include <config.h>
+
+#include <alloca.h>
+
+#include <string.h>
+#include <stdlib.h>
+
+#ifdef emacs
+# include "lisp.h"
+# include "blockinput.h"
+# ifdef EMACS_FREE
+#  undef free
+#  define free EMACS_FREE
+# endif
+#else
+# define memory_full() abort ()
+#endif
+
+/* If compiling with GCC 2, this file's not needed.  */
+#if !defined (__GNUC__) || __GNUC__ < 2
+
+/* If someone has defined alloca as a macro,
+   there must be some other way alloca is supposed to work.  */
+# ifndef alloca
+
+#  ifdef emacs
+#   ifdef static
+/* actually, only want this if static is defined as ""
+   -- this is for usg, in which emacs must undefine static
+   in order to make unexec workable
+   */
+#    ifndef STACK_DIRECTION
+you
+lose
+-- must know STACK_DIRECTION at compile-time
+/* Using #error here is not wise since this file should work for
+   old and obscure compilers.  */
+#    endif /* STACK_DIRECTION undefined */
+#   endif /* static */
+#  endif /* emacs */
+
+/* If your stack is a linked list of frames, you have to
+   provide an "address metric" ADDRESS_FUNCTION macro.  */
+
+#  if defined (CRAY) && defined (CRAY_STACKSEG_END)
+long i00afunc ();
+#   define ADDRESS_FUNCTION(arg) (char *) i00afunc (&(arg))
+#  else
+#   define ADDRESS_FUNCTION(arg) &(arg)
+#  endif
+
+/* Define STACK_DIRECTION if you know the direction of stack
+   growth for your system; otherwise it will be automatically
+   deduced at run-time.
+
+   STACK_DIRECTION > 0 => grows toward higher addresses
+   STACK_DIRECTION < 0 => grows toward lower addresses
+   STACK_DIRECTION = 0 => direction of growth unknown  */
+
+#  ifndef STACK_DIRECTION
+#   define STACK_DIRECTION      0       /* Direction unknown.  */
+#  endif
+
+#  if STACK_DIRECTION != 0
+
+#   define STACK_DIR    STACK_DIRECTION /* Known at compile-time.  */
+
+#  else /* STACK_DIRECTION == 0; need run-time code.  */
+
+static int stack_dir;           /* 1 or -1 once known.  */
+#   define STACK_DIR    stack_dir
+
+static int
+find_stack_direction (int *addr, int depth)
+{
+  int dir, dummy = 0;
+  if (! addr)
+    addr = &dummy;
+  *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1;
+  dir = depth ? find_stack_direction (addr, depth - 1) : 0;
+  return dir + dummy;
+}
+
+#  endif /* STACK_DIRECTION == 0 */
+
+/* An "alloca header" is used to:
+   (a) chain together all alloca'ed blocks;
+   (b) keep track of stack depth.
+
+   It is very important that sizeof(header) agree with malloc
+   alignment chunk size.  The following default should work okay.  */
+
+#  ifndef       ALIGN_SIZE
+#   define ALIGN_SIZE   sizeof(double)
+#  endif
+
+typedef union hdr
+{
+  char align[ALIGN_SIZE];       /* To force sizeof(header).  */
+  struct
+    {
+      union hdr *next;          /* For chaining headers.  */
+      char *deep;               /* For stack depth measure.  */
+    } h;
+} header;
+
+static header *last_alloca_header = NULL;       /* -> last alloca header.  */
+
+/* Return a pointer to at least SIZE bytes of storage,
+   which will be automatically reclaimed upon exit from
+   the procedure that called alloca.  Originally, this space
+   was supposed to be taken from the current stack frame of the
+   caller, but that method cannot be made to work for some
+   implementations of C, for example under Gould's UTX/32.  */
+
+void *
+alloca (size_t size)
+{
+  auto char probe;              /* Probes stack depth: */
+  register char *depth = ADDRESS_FUNCTION (probe);
+
+#  if STACK_DIRECTION == 0
+  if (STACK_DIR == 0)           /* Unknown growth direction.  */
+    STACK_DIR = find_stack_direction (NULL, (size & 1) + 20);
+#  endif
+
+  /* Reclaim garbage, defined as all alloca'd storage that
+     was allocated from deeper in the stack than currently.  */
+
+  {
+    register header *hp;        /* Traverses linked list.  */
+
+#  ifdef emacs
+    BLOCK_INPUT;
+#  endif
+
+    for (hp = last_alloca_header; hp != NULL;)
+      if ((STACK_DIR > 0 && hp->h.deep > depth)
+          || (STACK_DIR < 0 && hp->h.deep < depth))
+        {
+          register header *np = hp->h.next;
+
+          free (hp);            /* Collect garbage.  */
+
+          hp = np;              /* -> next header.  */
+        }
+      else
+        break;                  /* Rest are not deeper.  */
+
+    last_alloca_header = hp;    /* -> last valid storage.  */
+
+#  ifdef emacs
+    UNBLOCK_INPUT;
+#  endif
+  }
+
+  if (size == 0)
+    return NULL;                /* No allocation required.  */
+
+  /* Allocate combined header + user data storage.  */
+
+  {
+    /* Address of header.  */
+    register header *new;
+
+    size_t combined_size = sizeof (header) + size;
+    if (combined_size < sizeof (header))
+      memory_full ();
+
+    new = malloc (combined_size);
+
+    if (! new)
+      memory_full ();
+
+    new->h.next = last_alloca_header;
+    new->h.deep = depth;
+
+    last_alloca_header = new;
+
+    /* User storage begins just after header.  */
+
+    return (void *) (new + 1);
+  }
+}
+
+#  if defined (CRAY) && defined (CRAY_STACKSEG_END)
+
+#   ifdef DEBUG_I00AFUNC
+#    include <stdio.h>
+#   endif
+
+#   ifndef CRAY_STACK
+#    define CRAY_STACK
+#    ifndef CRAY2
+/* Stack structures for CRAY-1, CRAY X-MP, and CRAY Y-MP */
+struct stack_control_header
+  {
+    long shgrow:32;             /* Number of times stack has grown.  */
+    long shaseg:32;             /* Size of increments to stack.  */
+    long shhwm:32;              /* High water mark of stack.  */
+    long shsize:32;             /* Current size of stack (all segments).  */
+  };
+
+/* The stack segment linkage control information occurs at
+   the high-address end of a stack segment.  (The stack
+   grows from low addresses to high addresses.)  The initial
+   part of the stack segment linkage control information is
+   0200 (octal) words.  This provides for register storage
+   for the routine which overflows the stack.  */
+
+struct stack_segment_linkage
+  {
+    long ss[0200];              /* 0200 overflow words.  */
+    long sssize:32;             /* Number of words in this segment.  */
+    long ssbase:32;             /* Offset to stack base.  */
+    long:32;
+    long sspseg:32;             /* Offset to linkage control of previous
+                                   segment of stack.  */
+    long:32;
+    long sstcpt:32;             /* Pointer to task common address block.  */
+    long sscsnm;                /* Private control structure number for
+                                   microtasking.  */
+    long ssusr1;                /* Reserved for user.  */
+    long ssusr2;                /* Reserved for user.  */
+    long sstpid;                /* Process ID for pid based multi-tasking.  */
+    long ssgvup;                /* Pointer to multitasking thread giveup.  */
+    long sscray[7];             /* Reserved for Cray Research.  */
+    long ssa0;
+    long ssa1;
+    long ssa2;
+    long ssa3;
+    long ssa4;
+    long ssa5;
+    long ssa6;
+    long ssa7;
+    long sss0;
+    long sss1;
+    long sss2;
+    long sss3;
+    long sss4;
+    long sss5;
+    long sss6;
+    long sss7;
+  };
+
+#    else /* CRAY2 */
+/* The following structure defines the vector of words
+   returned by the STKSTAT library routine.  */
+struct stk_stat
+  {
+    long now;                   /* Current total stack size.  */
+    long maxc;                  /* Amount of contiguous space which would
+                                   be required to satisfy the maximum
+                                   stack demand to date.  */
+    long high_water;            /* Stack high-water mark.  */
+    long overflows;             /* Number of stack overflow ($STKOFEN) calls.  
*/
+    long hits;                  /* Number of internal buffer hits.  */
+    long extends;               /* Number of block extensions.  */
+    long stko_mallocs;          /* Block allocations by $STKOFEN.  */
+    long underflows;            /* Number of stack underflow calls ($STKRETN). 
 */
+    long stko_free;             /* Number of deallocations by $STKRETN.  */
+    long stkm_free;             /* Number of deallocations by $STKMRET.  */
+    long segments;              /* Current number of stack segments.  */
+    long maxs;                  /* Maximum number of stack segments so far.  */
+    long pad_size;              /* Stack pad size.  */
+    long current_address;       /* Current stack segment address.  */
+    long current_size;          /* Current stack segment size.  This
+                                   number is actually corrupted by STKSTAT to
+                                   include the fifteen word trailer area.  */
+    long initial_address;       /* Address of initial segment.  */
+    long initial_size;          /* Size of initial segment.  */
+  };
+
+/* The following structure describes the data structure which trails
+   any stack segment.  I think that the description in 'asdef' is
+   out of date.  I only describe the parts that I am sure about.  */
+
+struct stk_trailer
+  {
+    long this_address;          /* Address of this block.  */
+    long this_size;             /* Size of this block (does not include
+                                   this trailer).  */
+    long unknown2;
+    long unknown3;
+    long link;                  /* Address of trailer block of previous
+                                   segment.  */
+    long unknown5;
+    long unknown6;
+    long unknown7;
+    long unknown8;
+    long unknown9;
+    long unknown10;
+    long unknown11;
+    long unknown12;
+    long unknown13;
+    long unknown14;
+  };
+
+#    endif /* CRAY2 */
+#   endif /* not CRAY_STACK */
+
+#   ifdef CRAY2
+/* Determine a "stack measure" for an arbitrary ADDRESS.
+   I doubt that "lint" will like this much.  */
+
+static long
+i00afunc (long *address)
+{
+  struct stk_stat status;
+  struct stk_trailer *trailer;
+  long *block, size;
+  long result = 0;
+
+  /* We want to iterate through all of the segments.  The first
+     step is to get the stack status structure.  We could do this
+     more quickly and more directly, perhaps, by referencing the
+     $LM00 common block, but I know that this works.  */
+
+  STKSTAT (&status);
+
+  /* Set up the iteration.  */
+
+  trailer = (struct stk_trailer *) (status.current_address
+                                    + status.current_size
+                                    - 15);
+
+  /* There must be at least one stack segment.  Therefore it is
+     a fatal error if "trailer" is null.  */
+
+  if (trailer == 0)
+    abort ();
+
+  /* Discard segments that do not contain our argument address.  */
+
+  while (trailer != 0)
+    {
+      block = (long *) trailer->this_address;
+      size = trailer->this_size;
+      if (block == 0 || size == 0)
+        abort ();
+      trailer = (struct stk_trailer *) trailer->link;
+      if ((block <= address) && (address < (block + size)))
+        break;
+    }
+
+  /* Set the result to the offset in this segment and add the sizes
+     of all predecessor segments.  */
+
+  result = address - block;
+
+  if (trailer == 0)
+    {
+      return result;
+    }
+
+  do
+    {
+      if (trailer->this_size <= 0)
+        abort ();
+      result += trailer->this_size;
+      trailer = (struct stk_trailer *) trailer->link;
+    }
+  while (trailer != 0);
+
+  /* We are done.  Note that if you present a bogus address (one
+     not in any segment), you will get a different number back, formed
+     from subtracting the address of the first block.  This is probably
+     not what you want.  */
+
+  return (result);
+}
+
+#   else /* not CRAY2 */
+/* Stack address function for a CRAY-1, CRAY X-MP, or CRAY Y-MP.
+   Determine the number of the cell within the stack,
+   given the address of the cell.  The purpose of this
+   routine is to linearize, in some sense, stack addresses
+   for alloca.  */
+
+static long
+i00afunc (long address)
+{
+  long stkl = 0;
+
+  long size, pseg, this_segment, stack;
+  long result = 0;
+
+  struct stack_segment_linkage *ssptr;
+
+  /* Register B67 contains the address of the end of the
+     current stack segment.  If you (as a subprogram) store
+     your registers on the stack and find that you are past
+     the contents of B67, you have overflowed the segment.
+
+     B67 also points to the stack segment linkage control
+     area, which is what we are really interested in.  */
+
+  stkl = CRAY_STACKSEG_END ();
+  ssptr = (struct stack_segment_linkage *) stkl;
+
+  /* If one subtracts 'size' from the end of the segment,
+     one has the address of the first word of the segment.
+
+     If this is not the first segment, 'pseg' will be
+     nonzero.  */
+
+  pseg = ssptr->sspseg;
+  size = ssptr->sssize;
+
+  this_segment = stkl - size;
+
+  /* It is possible that calling this routine itself caused
+     a stack overflow.  Discard stack segments which do not
+     contain the target address.  */
+
+  while (!(this_segment <= address && address <= stkl))
+    {
+#    ifdef DEBUG_I00AFUNC
+      fprintf (stderr, "%011o %011o %011o\n", this_segment, address, stkl);
+#    endif
+      if (pseg == 0)
+        break;
+      stkl = stkl - pseg;
+      ssptr = (struct stack_segment_linkage *) stkl;
+      size = ssptr->sssize;
+      pseg = ssptr->sspseg;
+      this_segment = stkl - size;
+    }
+
+  result = address - this_segment;
+
+  /* If you subtract pseg from the current end of the stack,
+     you get the address of the previous stack segment's end.
+     This seems a little convoluted to me, but I'll bet you save
+     a cycle somewhere.  */
+
+  while (pseg != 0)
+    {
+#    ifdef DEBUG_I00AFUNC
+      fprintf (stderr, "%011o %011o\n", pseg, size);
+#    endif
+      stkl = stkl - pseg;
+      ssptr = (struct stack_segment_linkage *) stkl;
+      size = ssptr->sssize;
+      pseg = ssptr->sspseg;
+      result += size;
+    }
+  return (result);
+}
+
+#   endif /* not CRAY2 */
+#  endif /* CRAY */
+
+# endif /* no alloca */
+#endif /* not GCC 2 */
diff --git a/lib/alloca.in.h b/lib/alloca.in.h
index c36bdf9..19aea41 100644
--- a/lib/alloca.in.h
+++ b/lib/alloca.in.h
@@ -1,6 +1,6 @@
 /* Memory allocation on the stack.
 
-   Copyright (C) 1995, 1999, 2001-2004, 2006-2012 Free Software Foundation,
+   Copyright (C) 1995, 1999, 2001-2004, 2006-2013 Free Software Foundation,
    Inc.
 
    This program is free software; you can redistribute it and/or modify it
diff --git a/lib/arpa_inet.in.h b/lib/arpa_inet.in.h
index e580723..5344a92 100644
--- a/lib/arpa_inet.in.h
+++ b/lib/arpa_inet.in.h
@@ -1,6 +1,6 @@
 /* A GNU-like <arpa/inet.h>.
 
-   Copyright (C) 2005-2006, 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2005-2006, 2008-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/asnprintf.c b/lib/asnprintf.c
index 778068f..8c399b2 100644
--- a/lib/asnprintf.c
+++ b/lib/asnprintf.c
@@ -1,5 +1,5 @@
 /* Formatted output to strings.
-   Copyright (C) 1999, 2002, 2006, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2002, 2006, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/basename-lgpl.c b/lib/basename-lgpl.c
index 8ddbfc3..5e89d26 100644
--- a/lib/basename-lgpl.c
+++ b/lib/basename-lgpl.c
@@ -1,6 +1,6 @@
 /* basename.c -- return the last element in a file name
 
-   Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2012 Free Software
+   Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2013 Free Software
    Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/binary-io.h b/lib/binary-io.h
index 30315e1..b2095a2 100644
--- a/lib/binary-io.h
+++ b/lib/binary-io.h
@@ -1,5 +1,5 @@
 /* Binary mode I/O.
-   Copyright (C) 2001, 2003, 2005, 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2003, 2005, 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/bind.c b/lib/bind.c
index 1a2a3b6..e26f88e 100644
--- a/lib/bind.c
+++ b/lib/bind.c
@@ -1,6 +1,6 @@
 /* bind.c --- wrappers for Windows bind function
 
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/btowc.c b/lib/btowc.c
index 485e995..aca5742 100644
--- a/lib/btowc.c
+++ b/lib/btowc.c
@@ -1,5 +1,5 @@
 /* Convert unibyte character to wide character.
-   Copyright (C) 2008, 2010-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2010-2013 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2008.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/byteswap.in.h b/lib/byteswap.in.h
index a9baa68..6c7ab6d 100644
--- a/lib/byteswap.in.h
+++ b/lib/byteswap.in.h
@@ -1,5 +1,5 @@
 /* byteswap.h - Byte swapping
-   Copyright (C) 2005, 2007, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2007, 2009-2013 Free Software Foundation, Inc.
    Written by Oskar Liljeblad <address@hidden>, 2005.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/c-ctype.c b/lib/c-ctype.c
index 6b388fa..ccd8d94 100644
--- a/lib/c-ctype.c
+++ b/lib/c-ctype.c
@@ -1,6 +1,6 @@
 /* Character handling in C locale.
 
-   Copyright 2000-2003, 2006, 2009-2012 Free Software Foundation, Inc.
+   Copyright 2000-2003, 2006, 2009-2013 Free Software Foundation, Inc.
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/c-ctype.h b/lib/c-ctype.h
index 6ef0550..64bae06 100644
--- a/lib/c-ctype.h
+++ b/lib/c-ctype.h
@@ -5,7 +5,7 @@
    <ctype.h> functions' behaviour depends on the current locale set via
    setlocale.
 
-   Copyright (C) 2000-2003, 2006, 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2000-2003, 2006, 2008-2013 Free Software Foundation, Inc.
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/c-strcase.h b/lib/c-strcase.h
index 4d8b60c..e484aa8 100644
--- a/lib/c-strcase.h
+++ b/lib/c-strcase.h
@@ -1,5 +1,5 @@
 /* Case-insensitive string comparison functions in C locale.
-   Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2012 Free Software
+   Copyright (C) 1995-1996, 2001, 2003, 2005, 2009-2013 Free Software
    Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/lib/c-strcasecmp.c b/lib/c-strcasecmp.c
index 6983195..765b25a 100644
--- a/lib/c-strcasecmp.c
+++ b/lib/c-strcasecmp.c
@@ -1,5 +1,5 @@
 /* c-strcasecmp.c -- case insensitive string comparator in C locale
-   Copyright (C) 1998-1999, 2005-2006, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 1998-1999, 2005-2006, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/c-strcaseeq.h b/lib/c-strcaseeq.h
index 25e6e07..53ce1e1 100644
--- a/lib/c-strcaseeq.h
+++ b/lib/c-strcaseeq.h
@@ -1,5 +1,5 @@
 /* Optimized case-insensitive string comparison in C locale.
-   Copyright (C) 2001-2002, 2007, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2001-2002, 2007, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify it
    under the terms of the GNU Lesser General Public License as published
diff --git a/lib/c-strncasecmp.c b/lib/c-strncasecmp.c
index dbec89e..ad5f4f6 100644
--- a/lib/c-strncasecmp.c
+++ b/lib/c-strncasecmp.c
@@ -1,5 +1,5 @@
 /* c-strncasecmp.c -- case insensitive string comparator in C locale
-   Copyright (C) 1998-1999, 2005-2006, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 1998-1999, 2005-2006, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c
index 16550cf..5451791 100644
--- a/lib/canonicalize-lgpl.c
+++ b/lib/canonicalize-lgpl.c
@@ -1,5 +1,5 @@
 /* Return the canonical absolute name of a given file.
-   Copyright (C) 1996-2012 Free Software Foundation, Inc.
+   Copyright (C) 1996-2013 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    This program is free software: you can redistribute it and/or modify
@@ -16,16 +16,16 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #ifndef _LIBC
+/* Don't use __attribute__ __nonnull__ in this compilation unit.  Otherwise gcc
+   optimizes away the name == NULL test below.  */
+# define _GL_ARG_NONNULL(params)
+
 # define _GL_USE_STDLIB_ALLOC 1
 # include <config.h>
 #endif
 
 #if !HAVE_CANONICALIZE_FILE_NAME || !FUNC_REALPATH_WORKS || defined _LIBC
 
-/* Don't use __attribute__ __nonnull__ in this compilation unit.  Otherwise gcc
-   optimizes away the name == NULL test below.  */
-#define _GL_ARG_NONNULL(params)
-
 /* Specification.  */
 #include <stdlib.h>
 
@@ -51,6 +51,7 @@
 # define __realpath realpath
 # include "pathmax.h"
 # include "malloca.h"
+# include "dosname.h"
 # if HAVE_GETCWD
 #  if IN_RELOCWRAPPER
     /* When building the relocatable program wrapper, use the system's getcwd
@@ -101,6 +102,7 @@ __realpath (const char *name, char *resolved)
   const char *start, *end, *rpath_limit;
   long int path_max;
   int num_links = 0;
+  size_t prefix_len;
 
   if (name == NULL)
     {
@@ -143,7 +145,11 @@ __realpath (const char *name, char *resolved)
     rpath = resolved;
   rpath_limit = rpath + path_max;
 
-  if (name[0] != '/')
+  /* This is always zero for Posix hosts, but can be 2 for MS-Windows
+     and MS-DOS X:/foo/bar file names.  */
+  prefix_len = FILE_SYSTEM_PREFIX_LEN (name);
+
+  if (!IS_ABSOLUTE_FILE_NAME (name))
     {
       if (!__getcwd (rpath, path_max))
         {
@@ -151,20 +157,28 @@ __realpath (const char *name, char *resolved)
           goto error;
         }
       dest = strchr (rpath, '\0');
+      start = name;
+      prefix_len = FILE_SYSTEM_PREFIX_LEN (rpath);
     }
   else
     {
-      rpath[0] = '/';
-      dest = rpath + 1;
+      dest = rpath;
+      if (prefix_len)
+        {
+          memcpy (rpath, name, prefix_len);
+          dest += prefix_len;
+        }
+      *dest++ = '/';
       if (DOUBLE_SLASH_IS_DISTINCT_ROOT)
         {
-          if (name[1] == '/' && name[2] != '/')
+          if (ISSLASH (name[1]) && !ISSLASH (name[2]) && !prefix_len)
             *dest++ = '/';
           *dest = '\0';
         }
+      start = name + prefix_len;
     }
 
-  for (start = end = name; *start; start = end)
+  for (end = start; *start; start = end)
     {
 #ifdef _LIBC
       struct stat64 st;
@@ -174,11 +188,11 @@ __realpath (const char *name, char *resolved)
       int n;
 
       /* Skip sequence of multiple path-separators.  */
-      while (*start == '/')
+      while (ISSLASH (*start))
         ++start;
 
       /* Find end of path component.  */
-      for (end = start; *end && *end != '/'; ++end)
+      for (end = start; *end && !ISSLASH (*end); ++end)
         /* Nothing.  */;
 
       if (end - start == 0)
@@ -188,17 +202,19 @@ __realpath (const char *name, char *resolved)
       else if (end - start == 2 && start[0] == '.' && start[1] == '.')
         {
           /* Back up to previous component, ignore if at root already.  */
-          if (dest > rpath + 1)
-            while ((--dest)[-1] != '/');
-          if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rpath + 1
-              && *dest == '/' && dest[1] != '/')
+          if (dest > rpath + prefix_len + 1)
+            for (--dest; dest > rpath && !ISSLASH (dest[-1]); --dest)
+              continue;
+          if (DOUBLE_SLASH_IS_DISTINCT_ROOT
+              && dest == rpath + 1 && !prefix_len
+              && ISSLASH (*dest) && !ISSLASH (dest[1]))
             dest++;
         }
       else
         {
           size_t new_size;
 
-          if (dest[-1] != '/')
+          if (!ISSLASH (dest[-1]))
             *dest++ = '/';
 
           if (dest + (end - start) >= rpath_limit)
@@ -209,7 +225,7 @@ __realpath (const char *name, char *resolved)
               if (resolved)
                 {
                   __set_errno (ENAMETOOLONG);
-                  if (dest > rpath + 1)
+                  if (dest > rpath + prefix_len + 1)
                     dest--;
                   *dest = '\0';
                   goto error;
@@ -299,24 +315,32 @@ __realpath (const char *name, char *resolved)
               memmove (&extra_buf[n], end, len + 1);
               name = end = memcpy (extra_buf, buf, n);
 
-              if (buf[0] == '/')
+              if (IS_ABSOLUTE_FILE_NAME (buf))
                 {
-                  dest = rpath + 1;     /* It's an absolute symlink */
+                  size_t pfxlen = FILE_SYSTEM_PREFIX_LEN (buf);
+
+                  if (pfxlen)
+                    memcpy (rpath, buf, pfxlen);
+                  dest = rpath + pfxlen;
+                  *dest++ = '/'; /* It's an absolute symlink */
                   if (DOUBLE_SLASH_IS_DISTINCT_ROOT)
                     {
-                      if (buf[1] == '/' && buf[2] != '/')
+                      if (ISSLASH (buf[1]) && !ISSLASH (buf[2]) && !pfxlen)
                         *dest++ = '/';
                       *dest = '\0';
                     }
+                  /* Install the new prefix to be in effect hereafter.  */
+                  prefix_len = pfxlen;
                 }
               else
                 {
                   /* Back up to previous component, ignore if at root
                      already: */
-                  if (dest > rpath + 1)
-                    while ((--dest)[-1] != '/');
+                  if (dest > rpath + prefix_len + 1)
+                    for (--dest; dest > rpath && !ISSLASH (dest[-1]); --dest)
+                      continue;
                   if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rpath + 1
-                      && *dest == '/' && dest[1] != '/')
+                      && ISSLASH (*dest) && !ISSLASH (dest[1]) && !prefix_len)
                     dest++;
                 }
             }
@@ -327,10 +351,10 @@ __realpath (const char *name, char *resolved)
             }
         }
     }
-  if (dest > rpath + 1 && dest[-1] == '/')
+  if (dest > rpath + prefix_len + 1 && ISSLASH (dest[-1]))
     --dest;
-  if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rpath + 1
-      && *dest == '/' && dest[1] != '/')
+  if (DOUBLE_SLASH_IS_DISTINCT_ROOT && dest == rpath + 1 && !prefix_len
+      && ISSLASH (*dest) && !ISSLASH (dest[1]))
     dest++;
   *dest = '\0';
 
diff --git a/lib/ceil.c b/lib/ceil.c
index 810179c..3a264ae 100644
--- a/lib/ceil.c
+++ b/lib/ceil.c
@@ -1,5 +1,5 @@
 /* Round towards positive infinity.
-   Copyright (C) 2007, 2010-2012 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2010-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/close.c b/lib/close.c
index 2b6f598..02ff0b1 100644
--- a/lib/close.c
+++ b/lib/close.c
@@ -1,5 +1,5 @@
 /* close replacement.
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/config.charset b/lib/config.charset
index 58ac759..f15f5bb 100644
--- a/lib/config.charset
+++ b/lib/config.charset
@@ -1,7 +1,7 @@
 #! /bin/sh
 # Output a system dependent table of character encoding aliases.
 #
-#   Copyright (C) 2000-2004, 2006-2012 Free Software Foundation, Inc.
+#   Copyright (C) 2000-2004, 2006-2013 Free Software Foundation, Inc.
 #
 #   This program is free software; you can redistribute it and/or modify
 #   it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/connect.c b/lib/connect.c
index 303cd0b..03746f8 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -1,6 +1,6 @@
 /* connect.c --- wrappers for Windows connect function
 
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/dirent.in.h b/lib/dirent.in.h
index 8882415..aff6af3 100644
--- a/lib/dirent.in.h
+++ b/lib/dirent.in.h
@@ -1,5 +1,5 @@
 /* A GNU-like <dirent.h>.
-   Copyright (C) 2006-2012 Free Software Foundation, Inc.
+   Copyright (C) 2006-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/dirfd.c b/lib/dirfd.c
index 7013010..c535b17 100644
--- a/lib/dirfd.c
+++ b/lib/dirfd.c
@@ -1,6 +1,6 @@
 /* dirfd.c -- return the file descriptor associated with an open DIR*
 
-   Copyright (C) 2001, 2006, 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2006, 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/dirname-lgpl.c b/lib/dirname-lgpl.c
index 5d0cc07..90597ac 100644
--- a/lib/dirname-lgpl.c
+++ b/lib/dirname-lgpl.c
@@ -1,6 +1,6 @@
 /* dirname.c -- return all but the last element in a file name
 
-   Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2012 Free Software
+   Copyright (C) 1990, 1998, 2000-2001, 2003-2006, 2009-2013 Free Software
    Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/dirname.h b/lib/dirname.h
index ce77baf..4b5acd9 100644
--- a/lib/dirname.h
+++ b/lib/dirname.h
@@ -1,6 +1,6 @@
 /*  Take file names apart into directory and base names.
 
-    Copyright (C) 1998, 2001, 2003-2006, 2009-2012 Free Software Foundation,
+    Copyright (C) 1998, 2001, 2003-2006, 2009-2013 Free Software Foundation,
     Inc.
 
     This program is free software: you can redistribute it and/or modify
diff --git a/lib/dosname.h b/lib/dosname.h
index f4b1439..82d62e5 100644
--- a/lib/dosname.h
+++ b/lib/dosname.h
@@ -1,6 +1,6 @@
 /* File names on MS-DOS/Windows systems.
 
-   Copyright (C) 2000-2001, 2004-2006, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2000-2001, 2004-2006, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/dup2.c b/lib/dup2.c
new file mode 100644
index 0000000..89b40c4
--- /dev/null
+++ b/lib/dup2.c
@@ -0,0 +1,160 @@
+/* Duplicate an open file descriptor to a specified file descriptor.
+
+   Copyright (C) 1999, 2004-2007, 2009-2013 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* written by Paul Eggert */
+
+#include <config.h>
+
+/* Specification.  */
+#include <unistd.h>
+
+#include <errno.h>
+#include <fcntl.h>
+
+#if HAVE_DUP2
+
+# undef dup2
+
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+
+/* Get declarations of the native Windows API functions.  */
+#  define WIN32_LEAN_AND_MEAN
+#  include <windows.h>
+
+#  include "msvc-inval.h"
+
+/* Get _get_osfhandle.  */
+#  include "msvc-nothrow.h"
+
+static int
+ms_windows_dup2 (int fd, int desired_fd)
+{
+  int result;
+
+  /* If fd is closed, mingw hangs on dup2 (fd, fd).  If fd is open,
+     dup2 (fd, fd) returns 0, but all further attempts to use fd in
+     future dup2 calls will hang.  */
+  if (fd == desired_fd)
+    {
+      if ((HANDLE) _get_osfhandle (fd) == INVALID_HANDLE_VALUE)
+        {
+          errno = EBADF;
+          return -1;
+        }
+      return fd;
+    }
+
+  /* Wine 1.0.1 return 0 when desired_fd is negative but not -1:
+     http://bugs.winehq.org/show_bug.cgi?id=21289 */
+  if (desired_fd < 0)
+    {
+      errno = EBADF;
+      return -1;
+    }
+
+  TRY_MSVC_INVAL
+    {
+      result = dup2 (fd, desired_fd);
+    }
+  CATCH_MSVC_INVAL
+    {
+      errno = EBADF;
+      result = -1;
+    }
+  DONE_MSVC_INVAL;
+
+  if (result == 0)
+    result = desired_fd;
+
+  return result;
+}
+
+#  define dup2 ms_windows_dup2
+
+# endif
+
+int
+rpl_dup2 (int fd, int desired_fd)
+{
+  int result;
+
+# ifdef F_GETFL
+  /* On Linux kernels 2.6.26-2.6.29, dup2 (fd, fd) returns -EBADF.
+     On Cygwin 1.5.x, dup2 (1, 1) returns 0.
+     On Cygwin 1.7.17, dup2 (1, -1) dumps core.
+     On Haiku, dup2 (fd, fd) mistakenly clears FD_CLOEXEC.  */
+  if (desired_fd < 0)
+    fd = desired_fd;
+  if (fd == desired_fd)
+    return fcntl (fd, F_GETFL) == -1 ? -1 : fd;
+# endif
+
+  result = dup2 (fd, desired_fd);
+
+  /* Correct an errno value on FreeBSD 6.1 and Cygwin 1.5.x.  */
+  if (result == -1 && errno == EMFILE)
+    errno = EBADF;
+# if REPLACE_FCHDIR
+  if (fd != desired_fd && result != -1)
+    result = _gl_register_dup (fd, result);
+# endif
+  return result;
+}
+
+#else /* !HAVE_DUP2 */
+
+/* On older platforms, dup2 did not exist.  */
+
+# ifndef F_DUPFD
+static int
+dupfd (int fd, int desired_fd)
+{
+  int duplicated_fd = dup (fd);
+  if (duplicated_fd < 0 || duplicated_fd == desired_fd)
+    return duplicated_fd;
+  else
+    {
+      int r = dupfd (fd, desired_fd);
+      int e = errno;
+      close (duplicated_fd);
+      errno = e;
+      return r;
+    }
+}
+# endif
+
+int
+dup2 (int fd, int desired_fd)
+{
+  int result = fcntl (fd, F_GETFL) < 0 ? -1 : fd;
+  if (result == -1 || fd == desired_fd)
+    return result;
+  close (desired_fd);
+# ifdef F_DUPFD
+  result = fcntl (fd, F_DUPFD, desired_fd);
+#  if REPLACE_FCHDIR
+  if (0 <= result)
+    result = _gl_register_dup (fd, result);
+#  endif
+# else
+  result = dupfd (fd, desired_fd);
+# endif
+  if (result == -1 && (errno == EMFILE || errno == EINVAL))
+    errno = EBADF;
+  return result;
+}
+#endif /* !HAVE_DUP2 */
diff --git a/lib/duplocale.c b/lib/duplocale.c
index dd85efe..5a291b9 100644
--- a/lib/duplocale.c
+++ b/lib/duplocale.c
@@ -1,5 +1,5 @@
 /* Duplicate a locale object.
-   Copyright (C) 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2009-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/errno.in.h b/lib/errno.in.h
index 774c786..f2295cd 100644
--- a/lib/errno.in.h
+++ b/lib/errno.in.h
@@ -1,6 +1,6 @@
 /* A POSIX-like <errno.h>.
 
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h
index 5c934c0..f71ce2f 100644
--- a/lib/fcntl.in.h
+++ b/lib/fcntl.in.h
@@ -1,6 +1,6 @@
 /* Like <fcntl.h>, but with non-working flags defined to 0.
 
-   Copyright (C) 2006-2012 Free Software Foundation, Inc.
+   Copyright (C) 2006-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/fd-hook.c b/lib/fd-hook.c
index 39e25ea..cafd91c 100644
--- a/lib/fd-hook.c
+++ b/lib/fd-hook.c
@@ -1,5 +1,5 @@
 /* Hook for making making file descriptor functions close(), ioctl() 
extensible.
-   Copyright (C) 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2009-2013 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2009.
 
    This program is free software: you can redistribute it and/or modify it
diff --git a/lib/fd-hook.h b/lib/fd-hook.h
index b3b200d..397dbb0 100644
--- a/lib/fd-hook.h
+++ b/lib/fd-hook.h
@@ -1,5 +1,5 @@
 /* Hook for making making file descriptor functions close(), ioctl() 
extensible.
-   Copyright (C) 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2009-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify it
    under the terms of the GNU Lesser General Public License as published
diff --git a/lib/float+.h b/lib/float+.h
index fd4a9ed..1bd368c 100644
--- a/lib/float+.h
+++ b/lib/float+.h
@@ -1,5 +1,5 @@
 /* Supplemental information about the floating-point formats.
-   Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2007.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/lib/float.c b/lib/float.c
index 94c6cfd..37b0b49 100644
--- a/lib/float.c
+++ b/lib/float.c
@@ -1,5 +1,5 @@
 /* Auxiliary definitions for <float.h>.
-   Copyright (C) 2011-2012 Free Software Foundation, Inc.
+   Copyright (C) 2011-2013 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2011.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/float.in.h b/lib/float.in.h
index b3740b8..40875a2 100644
--- a/lib/float.in.h
+++ b/lib/float.in.h
@@ -1,6 +1,6 @@
 /* A correct <float.h>.
 
-   Copyright (C) 2007-2012 Free Software Foundation, Inc.
+   Copyright (C) 2007-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/flock.c b/lib/flock.c
index 3eb9abb..f15fe12 100644
--- a/lib/flock.c
+++ b/lib/flock.c
@@ -6,7 +6,7 @@
 
    Written by Richard W.M. Jones <rjones.at.redhat.com>
 
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
diff --git a/lib/floor.c b/lib/floor.c
index 7efbe9e..3dca6f5 100644
--- a/lib/floor.c
+++ b/lib/floor.c
@@ -1,5 +1,5 @@
 /* Round towards negative infinity.
-   Copyright (C) 2007, 2010-2012 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2010-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/frexp.c b/lib/frexp.c
index baeb462..eb2b379 100644
--- a/lib/frexp.c
+++ b/lib/frexp.c
@@ -1,5 +1,5 @@
 /* Split a double into fraction and mantissa.
-   Copyright (C) 2007-2012 Free Software Foundation, Inc.
+   Copyright (C) 2007-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/fstat.c b/lib/fstat.c
index 3f49e9b..121f4bf 100644
--- a/lib/fstat.c
+++ b/lib/fstat.c
@@ -1,5 +1,5 @@
 /* fstat() replacement.
-   Copyright (C) 2011-2012 Free Software Foundation, Inc.
+   Copyright (C) 2011-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -31,7 +31,7 @@
 #endif
 #undef __need_system_sys_stat_h
 
-static inline int
+static int
 orig_fstat (int fd, struct stat *buf)
 {
   return fstat (fd, buf);
@@ -51,7 +51,7 @@ orig_fstat (int fd, struct stat *buf)
 #endif
 
 #if HAVE_MSVC_INVALID_PARAMETER_HANDLER
-static inline int
+static int
 fstat_nothrow (int fd, struct stat *buf)
 {
   int result;
diff --git a/lib/full-read.c b/lib/full-read.c
index 68b273d..f884bb6 100644
--- a/lib/full-read.c
+++ b/lib/full-read.c
@@ -1,5 +1,5 @@
 /* An interface to read that retries after partial reads and interrupts.
-   Copyright (C) 2002-2003, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/full-read.h b/lib/full-read.h
index fdf2331..81f6edf 100644
--- a/lib/full-read.h
+++ b/lib/full-read.h
@@ -1,6 +1,6 @@
 /* An interface to read() that reads all it is asked to read.
 
-   Copyright (C) 2002, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/full-write.c b/lib/full-write.c
index 20d99b7..8f30798 100644
--- a/lib/full-write.c
+++ b/lib/full-write.c
@@ -1,6 +1,6 @@
 /* An interface to read and write that retries (if necessary) until complete.
 
-   Copyright (C) 1993-1994, 1997-2006, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 1993-1994, 1997-2006, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/full-write.h b/lib/full-write.h
index 018b25c..cb05bff 100644
--- a/lib/full-write.h
+++ b/lib/full-write.h
@@ -1,6 +1,6 @@
 /* An interface to write() that writes all it is asked to write.
 
-   Copyright (C) 2002-2003, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/gai_strerror.c b/lib/gai_strerror.c
index 8b36694..0205a78 100644
--- a/lib/gai_strerror.c
+++ b/lib/gai_strerror.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2012 Free Software
+/* Copyright (C) 1997, 2001-2002, 2004-2006, 2008-2013 Free Software
    Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Philip Blundell <address@hidden>, 1997.
diff --git a/lib/getaddrinfo.c b/lib/getaddrinfo.c
index e53a69b..9b0297c 100644
--- a/lib/getaddrinfo.c
+++ b/lib/getaddrinfo.c
@@ -1,5 +1,5 @@
 /* Get address information (partial implementation).
-   Copyright (C) 1997, 2001-2002, 2004-2012 Free Software Foundation, Inc.
+   Copyright (C) 1997, 2001-2002, 2004-2013 Free Software Foundation, Inc.
    Contributed by Simon Josefsson <address@hidden>.
 
    This program is free software; you can redistribute it and/or modify
@@ -15,12 +15,12 @@
    You should have received a copy of the GNU Lesser General Public License
    along with this program; if not, see <http://www.gnu.org/licenses/>.  */
 
-#include <config.h>
-
 /* Don't use __attribute__ __nonnull__ in this compilation unit.  Otherwise gcc
    optimizes away the sa == NULL test below.  */
 #define _GL_ARG_NONNULL(params)
 
+#include <config.h>
+
 #include <netdb.h>
 
 #if HAVE_NETINET_IN_H
@@ -109,7 +109,7 @@ use_win32_p (void)
 }
 #endif
 
-static inline bool
+static bool
 validate_family (int family)
 {
   /* FIXME: Support more families. */
diff --git a/lib/getlogin.c b/lib/getlogin.c
new file mode 100644
index 0000000..ebe7c33
--- /dev/null
+++ b/lib/getlogin.c
@@ -0,0 +1,41 @@
+/* Provide a working getlogin for systems which lack it.
+
+   Copyright (C) 2010-2013 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Bruno Haible, 2010.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <unistd.h>
+
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+#endif
+
+char *
+getlogin (void)
+{
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+  static char login_name[1024];
+  DWORD sz = sizeof (login_name);
+
+  if (GetUserName (login_name, &sz))
+    return login_name;
+#endif
+  return NULL;
+}
diff --git a/lib/getpeername.c b/lib/getpeername.c
index 02e3fad..307c9e2 100644
--- a/lib/getpeername.c
+++ b/lib/getpeername.c
@@ -1,6 +1,6 @@
 /* getpeername.c --- wrappers for Windows getpeername function
 
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/getsockname.c b/lib/getsockname.c
index 890c50e..daac0c0 100644
--- a/lib/getsockname.c
+++ b/lib/getsockname.c
@@ -1,6 +1,6 @@
 /* getsockname.c --- wrappers for Windows getsockname function
 
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/getsockopt.c b/lib/getsockopt.c
index 0bf74b0..c80487f 100644
--- a/lib/getsockopt.c
+++ b/lib/getsockopt.c
@@ -1,6 +1,6 @@
 /* getsockopt.c --- wrappers for Windows getsockopt function
 
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/gettext.h b/lib/gettext.h
index d130faa..2cc0e05 100644
--- a/lib/gettext.h
+++ b/lib/gettext.h
@@ -1,5 +1,5 @@
 /* Convenience header for conditional use of GNU <libintl.h>.
-   Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2012 Free Software
+   Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2013 Free Software
    Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/lib/iconv.c b/lib/iconv.c
index de2fb31..933730b 100644
--- a/lib/iconv.c
+++ b/lib/iconv.c
@@ -1,5 +1,5 @@
 /* Character set conversion.
-   Copyright (C) 1999-2001, 2007, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 1999-2001, 2007, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/iconv.in.h b/lib/iconv.in.h
index e150947..2e7efbe 100644
--- a/lib/iconv.in.h
+++ b/lib/iconv.in.h
@@ -1,6 +1,6 @@
 /* A GNU-like <iconv.h>.
 
-   Copyright (C) 2007-2012 Free Software Foundation, Inc.
+   Copyright (C) 2007-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/iconv_close.c b/lib/iconv_close.c
index d8b027a..3492f28 100644
--- a/lib/iconv_close.c
+++ b/lib/iconv_close.c
@@ -1,5 +1,5 @@
 /* Character set conversion.
-   Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/iconv_open.c b/lib/iconv_open.c
index c011241..eaf7c7d 100644
--- a/lib/iconv_open.c
+++ b/lib/iconv_open.c
@@ -1,5 +1,5 @@
 /* Character set conversion.
-   Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/iconveh.h b/lib/iconveh.h
index 4a4f506..8d792ac 100644
--- a/lib/iconveh.h
+++ b/lib/iconveh.h
@@ -1,5 +1,5 @@
 /* Character set conversion handler type.
-   Copyright (C) 2001-2007, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2001-2007, 2009-2013 Free Software Foundation, Inc.
    Written by Bruno Haible.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/inet_ntop.c b/lib/inet_ntop.c
index 0ccd997..96202e2 100644
--- a/lib/inet_ntop.c
+++ b/lib/inet_ntop.c
@@ -1,6 +1,6 @@
 /* inet_ntop.c -- convert IPv4 and IPv6 addresses from binary to text form
 
-   Copyright (C) 2005-2006, 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2005-2006, 2008-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/inet_pton.c b/lib/inet_pton.c
index 36e981a..08f1b20 100644
--- a/lib/inet_pton.c
+++ b/lib/inet_pton.c
@@ -1,6 +1,6 @@
 /* inet_pton.c -- convert IPv4 and IPv6 addresses from text to binary form
 
-   Copyright (C) 2006, 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/isinf.c b/lib/isinf.c
index 5efaa9d..24c32d3 100644
--- a/lib/isinf.c
+++ b/lib/isinf.c
@@ -1,5 +1,5 @@
 /* Test for positive or negative infinity.
-   Copyright (C) 2007-2012 Free Software Foundation, Inc.
+   Copyright (C) 2007-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/isnan.c b/lib/isnan.c
index 1faa28a..18fa5a2 100644
--- a/lib/isnan.c
+++ b/lib/isnan.c
@@ -1,5 +1,5 @@
 /* Test for NaN that does not need libm.
-   Copyright (C) 2007-2012 Free Software Foundation, Inc.
+   Copyright (C) 2007-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/isnand-nolibm.h b/lib/isnand-nolibm.h
index e9e64db..3510202 100644
--- a/lib/isnand-nolibm.h
+++ b/lib/isnand-nolibm.h
@@ -1,5 +1,5 @@
 /* Test for NaN that does not need libm.
-   Copyright (C) 2007-2012 Free Software Foundation, Inc.
+   Copyright (C) 2007-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/isnand.c b/lib/isnand.c
index 308caac..9bd092b 100644
--- a/lib/isnand.c
+++ b/lib/isnand.c
@@ -1,5 +1,5 @@
 /* Test for NaN that does not need libm.
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/isnanf.c b/lib/isnanf.c
index 6376ce0..503575f 100644
--- a/lib/isnanf.c
+++ b/lib/isnanf.c
@@ -1,5 +1,5 @@
 /* Test for NaN that does not need libm.
-   Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/isnanl.c b/lib/isnanl.c
index cfe2545..967eaff 100644
--- a/lib/isnanl.c
+++ b/lib/isnanl.c
@@ -1,5 +1,5 @@
 /* Test for NaN that does not need libm.
-   Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/itold.c b/lib/itold.c
index 0c41e2d..ff43bd0 100644
--- a/lib/itold.c
+++ b/lib/itold.c
@@ -1,5 +1,5 @@
 /* Replacement for 'int' to 'long double' conversion routine.
-   Copyright (C) 2011-2012 Free Software Foundation, Inc.
+   Copyright (C) 2011-2013 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2011.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/langinfo.in.h b/lib/langinfo.in.h
index 63b92fd..d60a980 100644
--- a/lib/langinfo.in.h
+++ b/lib/langinfo.in.h
@@ -1,5 +1,5 @@
 /* Substitute for and wrapper around <langinfo.h>.
-   Copyright (C) 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2009-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/listen.c b/lib/listen.c
index 28f3aaf..ea6eddc 100644
--- a/lib/listen.c
+++ b/lib/listen.c
@@ -1,6 +1,6 @@
 /* listen.c --- wrappers for Windows listen function
 
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/localcharset.c b/lib/localcharset.c
index c4a0596..e967ee5 100644
--- a/lib/localcharset.c
+++ b/lib/localcharset.c
@@ -1,6 +1,6 @@
 /* Determine a canonical name for the current locale's character encoding.
 
-   Copyright (C) 2000-2006, 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2000-2006, 2008-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/localcharset.h b/lib/localcharset.h
index b4467f6..4580edf 100644
--- a/lib/localcharset.h
+++ b/lib/localcharset.h
@@ -1,5 +1,5 @@
 /* Determine a canonical name for the current locale's character encoding.
-   Copyright (C) 2000-2003, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2000-2003, 2009-2013 Free Software Foundation, Inc.
    This file is part of the GNU CHARSET Library.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/lib/locale.in.h b/lib/locale.in.h
index 89b6745..ca67816 100644
--- a/lib/locale.in.h
+++ b/lib/locale.in.h
@@ -1,5 +1,5 @@
 /* A POSIX <locale.h>.
-   Copyright (C) 2007-2012 Free Software Foundation, Inc.
+   Copyright (C) 2007-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -14,16 +14,30 @@
    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifndef address@hidden@_LOCALE_H
-
 #if __GNUC__ >= 3
 @PRAGMA_SYSTEM_HEADER@
 #endif
 @PRAGMA_COLUMNS@
 
+#ifdef _GL_ALREADY_INCLUDING_LOCALE_H
+
+/* Special invocation conventions to handle Solaris header files
+   (through Solaris 10) when combined with gettext's libintl.h.  */
+
address@hidden@ @NEXT_LOCALE_H@
+
+#else
+/* Normal invocation convention.  */
+
+#ifndef address@hidden@_LOCALE_H
+
+#define _GL_ALREADY_INCLUDING_LOCALE_H
+
 /* The include_next requires a split double-inclusion guard.  */
 address@hidden@ @NEXT_LOCALE_H@
 
+#undef _GL_ALREADY_INCLUDING_LOCALE_H
+
 #ifndef address@hidden@_LOCALE_H
 #define address@hidden@_LOCALE_H
 
@@ -198,4 +212,5 @@ _GL_WARN_ON_USE (duplocale, "duplocale is buggy on some 
glibc systems - "
 #endif
 
 #endif /* address@hidden@_LOCALE_H */
+#endif /* ! _GL_ALREADY_INCLUDING_LOCALE_H */
 #endif /* address@hidden@_LOCALE_H */
diff --git a/lib/localeconv.c b/lib/localeconv.c
index c22860c..41396a0 100644
--- a/lib/localeconv.c
+++ b/lib/localeconv.c
@@ -1,5 +1,5 @@
 /* Query locale dependent information for formatting numbers.
-   Copyright (C) 2012 Free Software Foundation, Inc.
+   Copyright (C) 2012-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/log.c b/lib/log.c
index 9ec5eae..892721a 100644
--- a/lib/log.c
+++ b/lib/log.c
@@ -1,5 +1,5 @@
 /* Logarithm.
-   Copyright (C) 2012 Free Software Foundation, Inc.
+   Copyright (C) 2012-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/log1p.c b/lib/log1p.c
index 397b140..8c0788a 100644
--- a/lib/log1p.c
+++ b/lib/log1p.c
@@ -1,5 +1,5 @@
 /* Natural logarithm of 1 plus argument.
-   Copyright (C) 2012 Free Software Foundation, Inc.
+   Copyright (C) 2012-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/lstat.c b/lib/lstat.c
index fe20e61..b0873d3 100644
--- a/lib/lstat.c
+++ b/lib/lstat.c
@@ -1,6 +1,6 @@
 /* Work around a bug of lstat on some systems
 
-   Copyright (C) 1997-2006, 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 1997-2006, 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -35,7 +35,7 @@ typedef int dummy;
 # include <sys/stat.h>
 # undef __need_system_sys_stat_h
 
-static inline int
+static int
 orig_lstat (const char *filename, struct stat *buf)
 {
   return lstat (filename, buf);
diff --git a/lib/malloc.c b/lib/malloc.c
index 109c65c..8124cad 100644
--- a/lib/malloc.c
+++ b/lib/malloc.c
@@ -1,6 +1,6 @@
 /* malloc() function that is glibc compatible.
 
-   Copyright (C) 1997-1998, 2006-2007, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 1997-1998, 2006-2007, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/malloca.c b/lib/malloca.c
index 2d4c479..04ddc23 100644
--- a/lib/malloca.c
+++ b/lib/malloca.c
@@ -1,5 +1,5 @@
 /* Safe automatic memory allocation.
-   Copyright (C) 2003, 2006-2007, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2006-2007, 2009-2013 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2003.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/lib/malloca.h b/lib/malloca.h
index deb9bda..7747679 100644
--- a/lib/malloca.h
+++ b/lib/malloca.h
@@ -1,5 +1,5 @@
 /* Safe automatic memory allocation.
-   Copyright (C) 2003-2007, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2003-2007, 2009-2013 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2003.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/lib/math.c b/lib/math.c
new file mode 100644
index 0000000..ddb2ded
--- /dev/null
+++ b/lib/math.c
@@ -0,0 +1,3 @@
+#include <config.h>
+#define _GL_MATH_INLINE _GL_EXTERN_INLINE
+#include "math.h"
diff --git a/lib/math.in.h b/lib/math.in.h
index ee0fc95..46d0cf1 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -1,6 +1,6 @@
 /* A GNU-like <math.h>.
 
-   Copyright (C) 2002-2003, 2007-2012 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2007-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -28,6 +28,10 @@
 #ifndef address@hidden@_MATH_H
 #define address@hidden@_MATH_H
 
+_GL_INLINE_HEADER_BEGIN
+#ifndef _GL_MATH_INLINE
+# define _GL_MATH_INLINE _GL_INLINE
+#endif
 
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
@@ -78,17 +82,17 @@ func (long double l)                                        
        \
    classification macros with an argument of real-floating (that is,
    one of float, double, or long double).  */
 #define _GL_WARN_REAL_FLOATING_DECL(func) \
-static inline int                                                   \
+_GL_MATH_INLINE int                                                 \
 rpl_ ## func ## f (float f)                                         \
 {                                                                   \
   return func (f);                                                  \
 }                                                                   \
-static inline int                                                   \
+_GL_MATH_INLINE int                                                 \
 rpl_ ## func ## d (double d)                                        \
 {                                                                   \
   return func (d);                                                  \
 }                                                                   \
-static inline int                                                   \
+_GL_MATH_INLINE int                                                 \
 rpl_ ## func ## l (long double l)                                   \
 {                                                                   \
   return func (l);                                                  \
@@ -124,7 +128,7 @@ static void (*_gl_math_fix_itold) (long double *, int) = 
_Qp_itoq;
   /* The Compaq (ex-DEC) C 6.4 compiler and the Microsoft MSVC 9 compiler
      choke on the expression 0.0 / 0.0.  */
 #  if defined __DECC || defined _MSC_VER
-static float
+_GL_MATH_INLINE float
 _NaN ()
 {
   static float zero = 0.0f;
@@ -2265,6 +2269,7 @@ _GL_WARN_REAL_FLOATING_DECL (signbit);
 # endif
 #endif
 
+_GL_INLINE_HEADER_END
 
 #endif /* address@hidden@_MATH_H */
 #endif /* address@hidden@_MATH_H */
diff --git a/lib/mbrtowc.c b/lib/mbrtowc.c
index 5f2ec07..75d10bc 100644
--- a/lib/mbrtowc.c
+++ b/lib/mbrtowc.c
@@ -1,5 +1,5 @@
 /* Convert multibyte character to wide character.
-   Copyright (C) 1999-2002, 2005-2012 Free Software Foundation, Inc.
+   Copyright (C) 1999-2002, 2005-2013 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2008.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/mbsinit.c b/lib/mbsinit.c
index 79278d4..98ae1e6 100644
--- a/lib/mbsinit.c
+++ b/lib/mbsinit.c
@@ -1,5 +1,5 @@
 /* Test for initial conversion state.
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2008.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/mbtowc-impl.h b/lib/mbtowc-impl.h
index 3183f91..35b3528 100644
--- a/lib/mbtowc-impl.h
+++ b/lib/mbtowc-impl.h
@@ -1,5 +1,5 @@
 /* Convert multibyte character to wide character.
-   Copyright (C) 2011-2012 Free Software Foundation, Inc.
+   Copyright (C) 2011-2013 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2011.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/mbtowc.c b/lib/mbtowc.c
index e48b2f2..7777f0a 100644
--- a/lib/mbtowc.c
+++ b/lib/mbtowc.c
@@ -1,5 +1,5 @@
 /* Convert multibyte character to wide character.
-   Copyright (C) 2011-2012 Free Software Foundation, Inc.
+   Copyright (C) 2011-2013 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2011.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/memchr.c b/lib/memchr.c
index 7b6e258..6b28405 100644
--- a/lib/memchr.c
+++ b/lib/memchr.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2012
+/* Copyright (C) 1991, 1993, 1996-1997, 1999-2000, 2003-2004, 2006, 2008-2013
    Free Software Foundation, Inc.
 
    Based on strlen implementation by Torbjorn Granlund (address@hidden),
diff --git a/lib/msvc-inval.c b/lib/msvc-inval.c
index 7da3541..5e59da7 100644
--- a/lib/msvc-inval.c
+++ b/lib/msvc-inval.c
@@ -1,5 +1,5 @@
 /* Invalid parameter handler for MSVC runtime libraries.
-   Copyright (C) 2011-2012 Free Software Foundation, Inc.
+   Copyright (C) 2011-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/msvc-inval.h b/lib/msvc-inval.h
index ce6fcee..3ff7494 100644
--- a/lib/msvc-inval.h
+++ b/lib/msvc-inval.h
@@ -1,5 +1,5 @@
 /* Invalid parameter handler for MSVC runtime libraries.
-   Copyright (C) 2011-2012 Free Software Foundation, Inc.
+   Copyright (C) 2011-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/msvc-nothrow.c b/lib/msvc-nothrow.c
index 3e791c3..c17a9a2 100644
--- a/lib/msvc-nothrow.c
+++ b/lib/msvc-nothrow.c
@@ -1,6 +1,6 @@
 /* Wrappers that don't throw invalid parameter notifications
    with MSVC runtime libraries.
-   Copyright (C) 2011-2012 Free Software Foundation, Inc.
+   Copyright (C) 2011-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/msvc-nothrow.h b/lib/msvc-nothrow.h
index 573bc8e..80d4785 100644
--- a/lib/msvc-nothrow.h
+++ b/lib/msvc-nothrow.h
@@ -1,6 +1,6 @@
 /* Wrappers that don't throw invalid parameter notifications
    with MSVC runtime libraries.
-   Copyright (C) 2011-2012 Free Software Foundation, Inc.
+   Copyright (C) 2011-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/netdb.in.h b/lib/netdb.in.h
index 63ebd2d..dff665c 100644
--- a/lib/netdb.in.h
+++ b/lib/netdb.in.h
@@ -1,5 +1,5 @@
 /* Provide a netdb.h header file for systems lacking it (read: MinGW).
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
    Written by Simon Josefsson.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/lib/netinet_in.in.h b/lib/netinet_in.in.h
index a93dcdf..97ec58d 100644
--- a/lib/netinet_in.in.h
+++ b/lib/netinet_in.in.h
@@ -1,5 +1,5 @@
 /* Substitute for <netinet/in.h>.
-   Copyright (C) 2007-2012 Free Software Foundation, Inc.
+   Copyright (C) 2007-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/nl_langinfo.c b/lib/nl_langinfo.c
index 4b9bdbe..2210b7f 100644
--- a/lib/nl_langinfo.c
+++ b/lib/nl_langinfo.c
@@ -1,6 +1,6 @@
 /* nl_langinfo() replacement: query locale dependent information.
 
-   Copyright (C) 2007-2012 Free Software Foundation, Inc.
+   Copyright (C) 2007-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/nproc.c b/lib/nproc.c
index c4b151a..86aefe5 100644
--- a/lib/nproc.c
+++ b/lib/nproc.c
@@ -1,6 +1,6 @@
 /* Detect the number of processors.
 
-   Copyright (C) 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2009-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/nproc.h b/lib/nproc.h
index c5f6322..57689aa 100644
--- a/lib/nproc.h
+++ b/lib/nproc.h
@@ -1,6 +1,6 @@
 /* Detect the number of processors.
 
-   Copyright (C) 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2009-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/open.c b/lib/open.c
index 3a74813..b4d9c87 100644
--- a/lib/open.c
+++ b/lib/open.c
@@ -1,5 +1,5 @@
 /* Open a descriptor to a file.
-   Copyright (C) 2007-2012 Free Software Foundation, Inc.
+   Copyright (C) 2007-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -27,7 +27,7 @@
 #include <sys/types.h>
 #undef __need_system_fcntl_h
 
-static inline int
+static int
 orig_open (const char *filename, int flags, mode_t mode)
 {
   return open (filename, flags, mode);
diff --git a/lib/pathmax.h b/lib/pathmax.h
index 2361321..105edae 100644
--- a/lib/pathmax.h
+++ b/lib/pathmax.h
@@ -1,5 +1,5 @@
 /* Define PATH_MAX somehow.  Requires sys/types.h.
-   Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2012 Free Software
+   Copyright (C) 1992, 1999, 2001, 2003, 2005, 2009-2013 Free Software
    Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/lib/pipe.c b/lib/pipe.c
new file mode 100644
index 0000000..fc11967
--- /dev/null
+++ b/lib/pipe.c
@@ -0,0 +1,50 @@
+/* Create a pipe.
+   Copyright (C) 2009-2013 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License 
along
+   with this program; if not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <unistd.h>
+
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+/* Native Windows API.  */
+
+/* Get _pipe().  */
+# include <io.h>
+
+/* Get _O_BINARY.  */
+# include <fcntl.h>
+
+int
+pipe (int fd[2])
+{
+  /* Mingw changes fd to {-1,-1} on failure, but this violates
+     http://austingroupbugs.net/view.php?id=467 */
+  int tmp[2];
+  int result = _pipe (tmp, 4096, _O_BINARY);
+  if (!result)
+    {
+      fd[0] = tmp[0];
+      fd[1] = tmp[1];
+    }
+  return result;
+}
+
+#else
+
+# error "This platform lacks a pipe function, and Gnulib doesn't provide a 
replacement. This is a bug in Gnulib."
+
+#endif
diff --git a/lib/pipe2.c b/lib/pipe2.c
index 2c018d5..09952eb 100644
--- a/lib/pipe2.c
+++ b/lib/pipe2.c
@@ -1,5 +1,5 @@
 /* Create a pipe, with specific opening flags.
-   Copyright (C) 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2009-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/poll.c b/lib/poll.c
new file mode 100644
index 0000000..2767f5a
--- /dev/null
+++ b/lib/poll.c
@@ -0,0 +1,611 @@
+/* Emulation for poll(2)
+   Contributed by Paolo Bonzini.
+
+   Copyright 2001-2003, 2006-2013 Free Software Foundation, Inc.
+
+   This file is part of gnulib.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License 
along
+   with this program; if not, see <http://www.gnu.org/licenses/>.  */
+
+/* Tell gcc not to warn about the (nfd < 0) tests, below.  */
+#if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__
+# pragma GCC diagnostic ignored "-Wtype-limits"
+#endif
+
+#include <config.h>
+#include <alloca.h>
+
+#include <sys/types.h>
+
+/* Specification.  */
+#include <poll.h>
+
+#include <errno.h>
+#include <limits.h>
+#include <assert.h>
+
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# define WINDOWS_NATIVE
+# include <winsock2.h>
+# include <windows.h>
+# include <io.h>
+# include <stdio.h>
+# include <conio.h>
+# include "msvc-nothrow.h"
+#else
+# include <sys/time.h>
+# include <sys/socket.h>
+# include <sys/select.h>
+# include <unistd.h>
+#endif
+
+#ifdef HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif
+#ifdef HAVE_SYS_FILIO_H
+# include <sys/filio.h>
+#endif
+
+#include <time.h>
+
+#ifndef INFTIM
+# define INFTIM (-1)
+#endif
+
+/* BeOS does not have MSG_PEEK.  */
+#ifndef MSG_PEEK
+# define MSG_PEEK 0
+#endif
+
+#ifdef WINDOWS_NATIVE
+
+/* Optimized test whether a HANDLE refers to a console.
+   See <http://lists.gnu.org/archive/html/bug-gnulib/2009-08/msg00065.html>.  
*/
+#define IsConsoleHandle(h) (((intptr_t) (h) & 3) == 3)
+
+static BOOL
+IsSocketHandle (HANDLE h)
+{
+  WSANETWORKEVENTS ev;
+
+  if (IsConsoleHandle (h))
+    return FALSE;
+
+  /* Under Wine, it seems that getsockopt returns 0 for pipes too.
+     WSAEnumNetworkEvents instead distinguishes the two correctly.  */
+  ev.lNetworkEvents = 0xDEADBEEF;
+  WSAEnumNetworkEvents ((SOCKET) h, NULL, &ev);
+  return ev.lNetworkEvents != 0xDEADBEEF;
+}
+
+/* Declare data structures for ntdll functions.  */
+typedef struct _FILE_PIPE_LOCAL_INFORMATION {
+  ULONG NamedPipeType;
+  ULONG NamedPipeConfiguration;
+  ULONG MaximumInstances;
+  ULONG CurrentInstances;
+  ULONG InboundQuota;
+  ULONG ReadDataAvailable;
+  ULONG OutboundQuota;
+  ULONG WriteQuotaAvailable;
+  ULONG NamedPipeState;
+  ULONG NamedPipeEnd;
+} FILE_PIPE_LOCAL_INFORMATION, *PFILE_PIPE_LOCAL_INFORMATION;
+
+typedef struct _IO_STATUS_BLOCK
+{
+  union {
+    DWORD Status;
+    PVOID Pointer;
+  } u;
+  ULONG_PTR Information;
+} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
+
+typedef enum _FILE_INFORMATION_CLASS {
+  FilePipeLocalInformation = 24
+} FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
+
+typedef DWORD (WINAPI *PNtQueryInformationFile)
+         (HANDLE, IO_STATUS_BLOCK *, VOID *, ULONG, FILE_INFORMATION_CLASS);
+
+# ifndef PIPE_BUF
+#  define PIPE_BUF      512
+# endif
+
+/* Compute revents values for file handle H.  If some events cannot happen
+   for the handle, eliminate them from *P_SOUGHT.  */
+
+static int
+windows_compute_revents (HANDLE h, int *p_sought)
+{
+  int i, ret, happened;
+  INPUT_RECORD *irbuffer;
+  DWORD avail, nbuffer;
+  BOOL bRet;
+  IO_STATUS_BLOCK iosb;
+  FILE_PIPE_LOCAL_INFORMATION fpli;
+  static PNtQueryInformationFile NtQueryInformationFile;
+  static BOOL once_only;
+
+  switch (GetFileType (h))
+    {
+    case FILE_TYPE_PIPE:
+      if (!once_only)
+        {
+          NtQueryInformationFile = (PNtQueryInformationFile)
+            GetProcAddress (GetModuleHandle ("ntdll.dll"),
+                            "NtQueryInformationFile");
+          once_only = TRUE;
+        }
+
+      happened = 0;
+      if (PeekNamedPipe (h, NULL, 0, NULL, &avail, NULL) != 0)
+        {
+          if (avail)
+            happened |= *p_sought & (POLLIN | POLLRDNORM);
+        }
+      else if (GetLastError () == ERROR_BROKEN_PIPE)
+        happened |= POLLHUP;
+
+      else
+        {
+          /* It was the write-end of the pipe.  Check if it is writable.
+             If NtQueryInformationFile fails, optimistically assume the pipe is
+             writable.  This could happen on Windows 9x, where
+             NtQueryInformationFile is not available, or if we inherit a pipe
+             that doesn't permit FILE_READ_ATTRIBUTES access on the write end
+             (I think this should not happen since Windows XP SP2; WINE seems
+             fine too).  Otherwise, ensure that enough space is available for
+             atomic writes.  */
+          memset (&iosb, 0, sizeof (iosb));
+          memset (&fpli, 0, sizeof (fpli));
+
+          if (!NtQueryInformationFile
+              || NtQueryInformationFile (h, &iosb, &fpli, sizeof (fpli),
+                                         FilePipeLocalInformation)
+              || fpli.WriteQuotaAvailable >= PIPE_BUF
+              || (fpli.OutboundQuota < PIPE_BUF &&
+                  fpli.WriteQuotaAvailable == fpli.OutboundQuota))
+            happened |= *p_sought & (POLLOUT | POLLWRNORM | POLLWRBAND);
+        }
+      return happened;
+
+    case FILE_TYPE_CHAR:
+      ret = WaitForSingleObject (h, 0);
+      if (!IsConsoleHandle (h))
+        return ret == WAIT_OBJECT_0 ? *p_sought & ~(POLLPRI | POLLRDBAND) : 0;
+
+      nbuffer = avail = 0;
+      bRet = GetNumberOfConsoleInputEvents (h, &nbuffer);
+      if (bRet)
+        {
+          /* Input buffer.  */
+          *p_sought &= POLLIN | POLLRDNORM;
+          if (nbuffer == 0)
+            return POLLHUP;
+          if (!*p_sought)
+            return 0;
+
+          irbuffer = (INPUT_RECORD *) alloca (nbuffer * sizeof (INPUT_RECORD));
+          bRet = PeekConsoleInput (h, irbuffer, nbuffer, &avail);
+          if (!bRet || avail == 0)
+            return POLLHUP;
+
+          for (i = 0; i < avail; i++)
+            if (irbuffer[i].EventType == KEY_EVENT)
+              return *p_sought;
+          return 0;
+        }
+      else
+        {
+          /* Screen buffer.  */
+          *p_sought &= POLLOUT | POLLWRNORM | POLLWRBAND;
+          return *p_sought;
+        }
+
+    default:
+      ret = WaitForSingleObject (h, 0);
+      if (ret == WAIT_OBJECT_0)
+        return *p_sought & ~(POLLPRI | POLLRDBAND);
+
+      return *p_sought & (POLLOUT | POLLWRNORM | POLLWRBAND);
+    }
+}
+
+/* Convert fd_sets returned by select into revents values.  */
+
+static int
+windows_compute_revents_socket (SOCKET h, int sought, long lNetworkEvents)
+{
+  int happened = 0;
+
+  if ((lNetworkEvents & (FD_READ | FD_ACCEPT | FD_CLOSE)) == FD_ACCEPT)
+    happened |= (POLLIN | POLLRDNORM) & sought;
+
+  else if (lNetworkEvents & (FD_READ | FD_ACCEPT | FD_CLOSE))
+    {
+      int r, error;
+
+      char data[64];
+      WSASetLastError (0);
+      r = recv (h, data, sizeof (data), MSG_PEEK);
+      error = WSAGetLastError ();
+      WSASetLastError (0);
+
+      if (r > 0 || error == WSAENOTCONN)
+        happened |= (POLLIN | POLLRDNORM) & sought;
+
+      /* Distinguish hung-up sockets from other errors.  */
+      else if (r == 0 || error == WSAESHUTDOWN || error == WSAECONNRESET
+               || error == WSAECONNABORTED || error == WSAENETRESET)
+        happened |= POLLHUP;
+
+      else
+        happened |= POLLERR;
+    }
+
+  if (lNetworkEvents & (FD_WRITE | FD_CONNECT))
+    happened |= (POLLOUT | POLLWRNORM | POLLWRBAND) & sought;
+
+  if (lNetworkEvents & FD_OOB)
+    happened |= (POLLPRI | POLLRDBAND) & sought;
+
+  return happened;
+}
+
+#else /* !MinGW */
+
+/* Convert select(2) returned fd_sets into poll(2) revents values.  */
+static int
+compute_revents (int fd, int sought, fd_set *rfds, fd_set *wfds, fd_set *efds)
+{
+  int happened = 0;
+  if (FD_ISSET (fd, rfds))
+    {
+      int r;
+      int socket_errno;
+
+# if defined __MACH__ && defined __APPLE__
+      /* There is a bug in Mac OS X that causes it to ignore MSG_PEEK
+         for some kinds of descriptors.  Detect if this descriptor is a
+         connected socket, a server socket, or something else using a
+         0-byte recv, and use ioctl(2) to detect POLLHUP.  */
+      r = recv (fd, NULL, 0, MSG_PEEK);
+      socket_errno = (r < 0) ? errno : 0;
+      if (r == 0 || socket_errno == ENOTSOCK)
+        ioctl (fd, FIONREAD, &r);
+# else
+      char data[64];
+      r = recv (fd, data, sizeof (data), MSG_PEEK);
+      socket_errno = (r < 0) ? errno : 0;
+# endif
+      if (r == 0)
+        happened |= POLLHUP;
+
+      /* If the event happened on an unconnected server socket,
+         that's fine. */
+      else if (r > 0 || ( /* (r == -1) && */ socket_errno == ENOTCONN))
+        happened |= (POLLIN | POLLRDNORM) & sought;
+
+      /* Distinguish hung-up sockets from other errors.  */
+      else if (socket_errno == ESHUTDOWN || socket_errno == ECONNRESET
+               || socket_errno == ECONNABORTED || socket_errno == ENETRESET)
+        happened |= POLLHUP;
+
+      /* some systems can't use recv() on non-socket, including HP NonStop */
+      else if (socket_errno == ENOTSOCK)
+        happened |= (POLLIN | POLLRDNORM) & sought;
+
+      else
+        happened |= POLLERR;
+    }
+
+  if (FD_ISSET (fd, wfds))
+    happened |= (POLLOUT | POLLWRNORM | POLLWRBAND) & sought;
+
+  if (FD_ISSET (fd, efds))
+    happened |= (POLLPRI | POLLRDBAND) & sought;
+
+  return happened;
+}
+#endif /* !MinGW */
+
+int
+poll (struct pollfd *pfd, nfds_t nfd, int timeout)
+{
+#ifndef WINDOWS_NATIVE
+  fd_set rfds, wfds, efds;
+  struct timeval tv;
+  struct timeval *ptv;
+  int maxfd, rc;
+  nfds_t i;
+
+# ifdef _SC_OPEN_MAX
+  static int sc_open_max = -1;
+
+  if (nfd < 0
+      || (nfd > sc_open_max
+          && (sc_open_max != -1
+              || nfd > (sc_open_max = sysconf (_SC_OPEN_MAX)))))
+    {
+      errno = EINVAL;
+      return -1;
+    }
+# else /* !_SC_OPEN_MAX */
+#  ifdef OPEN_MAX
+  if (nfd < 0 || nfd > OPEN_MAX)
+    {
+      errno = EINVAL;
+      return -1;
+    }
+#  endif /* OPEN_MAX -- else, no check is needed */
+# endif /* !_SC_OPEN_MAX */
+
+  /* EFAULT is not necessary to implement, but let's do it in the
+     simplest case. */
+  if (!pfd && nfd)
+    {
+      errno = EFAULT;
+      return -1;
+    }
+
+  /* convert timeout number into a timeval structure */
+  if (timeout == 0)
+    {
+      ptv = &tv;
+      ptv->tv_sec = 0;
+      ptv->tv_usec = 0;
+    }
+  else if (timeout > 0)
+    {
+      ptv = &tv;
+      ptv->tv_sec = timeout / 1000;
+      ptv->tv_usec = (timeout % 1000) * 1000;
+    }
+  else if (timeout == INFTIM)
+    /* wait forever */
+    ptv = NULL;
+  else
+    {
+      errno = EINVAL;
+      return -1;
+    }
+
+  /* create fd sets and determine max fd */
+  maxfd = -1;
+  FD_ZERO (&rfds);
+  FD_ZERO (&wfds);
+  FD_ZERO (&efds);
+  for (i = 0; i < nfd; i++)
+    {
+      if (pfd[i].fd < 0)
+        continue;
+
+      if (pfd[i].events & (POLLIN | POLLRDNORM))
+        FD_SET (pfd[i].fd, &rfds);
+
+      /* see select(2): "the only exceptional condition detectable
+         is out-of-band data received on a socket", hence we push
+         POLLWRBAND events onto wfds instead of efds. */
+      if (pfd[i].events & (POLLOUT | POLLWRNORM | POLLWRBAND))
+        FD_SET (pfd[i].fd, &wfds);
+      if (pfd[i].events & (POLLPRI | POLLRDBAND))
+        FD_SET (pfd[i].fd, &efds);
+      if (pfd[i].fd >= maxfd
+          && (pfd[i].events & (POLLIN | POLLOUT | POLLPRI
+                               | POLLRDNORM | POLLRDBAND
+                               | POLLWRNORM | POLLWRBAND)))
+        {
+          maxfd = pfd[i].fd;
+          if (maxfd > FD_SETSIZE)
+            {
+              errno = EOVERFLOW;
+              return -1;
+            }
+        }
+    }
+
+  /* examine fd sets */
+  rc = select (maxfd + 1, &rfds, &wfds, &efds, ptv);
+  if (rc < 0)
+    return rc;
+
+  /* establish results */
+  rc = 0;
+  for (i = 0; i < nfd; i++)
+    if (pfd[i].fd < 0)
+      pfd[i].revents = 0;
+    else
+      {
+        int happened = compute_revents (pfd[i].fd, pfd[i].events,
+                                        &rfds, &wfds, &efds);
+        if (happened)
+          {
+            pfd[i].revents = happened;
+            rc++;
+          }
+      }
+
+  return rc;
+#else
+  static struct timeval tv0;
+  static HANDLE hEvent;
+  WSANETWORKEVENTS ev;
+  HANDLE h, handle_array[FD_SETSIZE + 2];
+  DWORD ret, wait_timeout, nhandles;
+  fd_set rfds, wfds, xfds;
+  BOOL poll_again;
+  MSG msg;
+  int rc = 0;
+  nfds_t i;
+
+  if (nfd < 0 || timeout < -1)
+    {
+      errno = EINVAL;
+      return -1;
+    }
+
+  if (!hEvent)
+    hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
+
+restart:
+  handle_array[0] = hEvent;
+  nhandles = 1;
+  FD_ZERO (&rfds);
+  FD_ZERO (&wfds);
+  FD_ZERO (&xfds);
+
+  /* Classify socket handles and create fd sets. */
+  for (i = 0; i < nfd; i++)
+    {
+      int sought = pfd[i].events;
+      pfd[i].revents = 0;
+      if (pfd[i].fd < 0)
+        continue;
+      if (!(sought & (POLLIN | POLLRDNORM | POLLOUT | POLLWRNORM | POLLWRBAND
+                      | POLLPRI | POLLRDBAND)))
+        continue;
+
+      h = (HANDLE) _get_osfhandle (pfd[i].fd);
+      assert (h != NULL);
+      if (IsSocketHandle (h))
+        {
+          int requested = FD_CLOSE;
+
+          /* see above; socket handles are mapped onto select.  */
+          if (sought & (POLLIN | POLLRDNORM))
+            {
+              requested |= FD_READ | FD_ACCEPT;
+              FD_SET ((SOCKET) h, &rfds);
+            }
+          if (sought & (POLLOUT | POLLWRNORM | POLLWRBAND))
+            {
+              requested |= FD_WRITE | FD_CONNECT;
+              FD_SET ((SOCKET) h, &wfds);
+            }
+          if (sought & (POLLPRI | POLLRDBAND))
+            {
+              requested |= FD_OOB;
+              FD_SET ((SOCKET) h, &xfds);
+            }
+
+          if (requested)
+            WSAEventSelect ((SOCKET) h, hEvent, requested);
+        }
+      else
+        {
+          /* Poll now.  If we get an event, do not poll again.  Also,
+             screen buffer handles are waitable, and they'll block until
+             a character is available.  windows_compute_revents eliminates
+             bits for the "wrong" direction. */
+          pfd[i].revents = windows_compute_revents (h, &sought);
+          if (sought)
+            handle_array[nhandles++] = h;
+          if (pfd[i].revents)
+            timeout = 0;
+        }
+    }
+
+  if (select (0, &rfds, &wfds, &xfds, &tv0) > 0)
+    {
+      /* Do MsgWaitForMultipleObjects anyway to dispatch messages, but
+         no need to call select again.  */
+      poll_again = FALSE;
+      wait_timeout = 0;
+    }
+  else
+    {
+      poll_again = TRUE;
+      if (timeout == INFTIM)
+        wait_timeout = INFINITE;
+      else
+        wait_timeout = timeout;
+    }
+
+  for (;;)
+    {
+      ret = MsgWaitForMultipleObjects (nhandles, handle_array, FALSE,
+                                       wait_timeout, QS_ALLINPUT);
+
+      if (ret == WAIT_OBJECT_0 + nhandles)
+        {
+          /* new input of some other kind */
+          BOOL bRet;
+          while ((bRet = PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) != 0)
+            {
+              TranslateMessage (&msg);
+              DispatchMessage (&msg);
+            }
+        }
+      else
+        break;
+    }
+
+  if (poll_again)
+    select (0, &rfds, &wfds, &xfds, &tv0);
+
+  /* Place a sentinel at the end of the array.  */
+  handle_array[nhandles] = NULL;
+  nhandles = 1;
+  for (i = 0; i < nfd; i++)
+    {
+      int happened;
+
+      if (pfd[i].fd < 0)
+        continue;
+      if (!(pfd[i].events & (POLLIN | POLLRDNORM |
+                             POLLOUT | POLLWRNORM | POLLWRBAND)))
+        continue;
+
+      h = (HANDLE) _get_osfhandle (pfd[i].fd);
+      if (h != handle_array[nhandles])
+        {
+          /* It's a socket.  */
+          WSAEnumNetworkEvents ((SOCKET) h, NULL, &ev);
+          WSAEventSelect ((SOCKET) h, 0, 0);
+
+          /* If we're lucky, WSAEnumNetworkEvents already provided a way
+             to distinguish FD_READ and FD_ACCEPT; this saves a recv later.  */
+          if (FD_ISSET ((SOCKET) h, &rfds)
+              && !(ev.lNetworkEvents & (FD_READ | FD_ACCEPT)))
+            ev.lNetworkEvents |= FD_READ | FD_ACCEPT;
+          if (FD_ISSET ((SOCKET) h, &wfds))
+            ev.lNetworkEvents |= FD_WRITE | FD_CONNECT;
+          if (FD_ISSET ((SOCKET) h, &xfds))
+            ev.lNetworkEvents |= FD_OOB;
+
+          happened = windows_compute_revents_socket ((SOCKET) h, pfd[i].events,
+                                                     ev.lNetworkEvents);
+        }
+      else
+        {
+          /* Not a socket.  */
+          int sought = pfd[i].events;
+          happened = windows_compute_revents (h, &sought);
+          nhandles++;
+        }
+
+       if ((pfd[i].revents |= happened) != 0)
+        rc++;
+    }
+
+  if (!rc && timeout == INFTIM)
+    {
+      SleepEx (1, TRUE);
+      goto restart;
+    }
+
+  return rc;
+#endif
+}
diff --git a/lib/poll.in.h b/lib/poll.in.h
new file mode 100644
index 0000000..3c0b48f
--- /dev/null
+++ b/lib/poll.in.h
@@ -0,0 +1,103 @@
+/* Header for poll(2) emulation
+   Contributed by Paolo Bonzini.
+
+   Copyright 2001-2003, 2007, 2009-2013 Free Software Foundation, Inc.
+
+   This file is part of gnulib.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License 
along
+   with this program; if not, see <http://www.gnu.org/licenses/>.  */
+
+#ifndef address@hidden@_POLL_H
+
+#if __GNUC__ >= 3
address@hidden@
+#endif
address@hidden@
+
+/* The include_next requires a split double-inclusion guard.  */
+#if @HAVE_POLL_H@
+# @INCLUDE_NEXT@ @NEXT_POLL_H@
+#endif
+
+#ifndef address@hidden@_POLL_H
+#define address@hidden@_POLL_H
+
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
+
+#if address@hidden@
+
+/* fake a poll(2) environment */
+# define POLLIN      0x0001      /* any readable data available   */
+# define POLLPRI     0x0002      /* OOB/Urgent readable data      */
+# define POLLOUT     0x0004      /* file descriptor is writable   */
+# define POLLERR     0x0008      /* some poll error occurred      */
+# define POLLHUP     0x0010      /* file descriptor was "hung up" */
+# define POLLNVAL    0x0020      /* requested events "invalid"    */
+# define POLLRDNORM  0x0040
+# define POLLRDBAND  0x0080
+# define POLLWRNORM  0x0100
+# define POLLWRBAND  0x0200
+
+# if !GNULIB_defined_poll_types
+
+struct pollfd
+{
+  int fd;                       /* which file descriptor to poll */
+  short events;                 /* events we are interested in   */
+  short revents;                /* events found on return        */
+};
+
+typedef unsigned long nfds_t;
+
+#  define GNULIB_defined_poll_types 1
+# endif
+
+/* Define INFTIM only if doing so conforms to POSIX.  */
+# if !defined (_POSIX_C_SOURCE) && !defined (_XOPEN_SOURCE)
+#  define INFTIM (-1)
+# endif
+
+#endif
+
+
+#if @GNULIB_POLL@
+# if @REPLACE_POLL@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef poll
+#   define poll rpl_poll
+#  endif
+_GL_FUNCDECL_RPL (poll, int, (struct pollfd *pfd, nfds_t nfd, int timeout));
+_GL_CXXALIAS_RPL (poll, int, (struct pollfd *pfd, nfds_t nfd, int timeout));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (poll, int, (struct pollfd *pfd, nfds_t nfd, int timeout));
+#  endif
+_GL_CXXALIAS_SYS (poll, int, (struct pollfd *pfd, nfds_t nfd, int timeout));
+# endif
+_GL_CXXALIASWARN (poll);
+#elif defined GNULIB_POSIXCHECK
+# undef poll
+# if HAVE_RAW_DECL_POLL
+_GL_WARN_ON_USE (poll, "poll is unportable - "
+                 "use gnulib module poll for portability");
+# endif
+#endif
+
+
+#endif /* address@hidden@_POLL_H */
+#endif /* address@hidden@_POLL_H */
diff --git a/lib/printf-args.c b/lib/printf-args.c
index c768883..73fa7a4 100644
--- a/lib/printf-args.c
+++ b/lib/printf-args.c
@@ -1,5 +1,5 @@
 /* Decomposed printf argument list.
-   Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2012 Free Software
+   Copyright (C) 1999, 2002-2003, 2005-2007, 2009-2013 Free Software
    Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/lib/printf-args.h b/lib/printf-args.h
index 0bc75ca..af7e72d 100644
--- a/lib/printf-args.h
+++ b/lib/printf-args.h
@@ -1,5 +1,5 @@
 /* Decomposed printf argument list.
-   Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2012 Free Software
+   Copyright (C) 1999, 2002-2003, 2006-2007, 2011-2013 Free Software
    Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/lib/printf-parse.c b/lib/printf-parse.c
index fcc302f..9a266df 100644
--- a/lib/printf-parse.c
+++ b/lib/printf-parse.c
@@ -1,5 +1,5 @@
 /* Formatted output to strings.
-   Copyright (C) 1999-2000, 2002-2003, 2006-2012 Free Software Foundation, Inc.
+   Copyright (C) 1999-2000, 2002-2003, 2006-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/printf-parse.h b/lib/printf-parse.h
index 94883c6..0d535fa 100644
--- a/lib/printf-parse.h
+++ b/lib/printf-parse.h
@@ -1,5 +1,5 @@
 /* Parse printf format string.
-   Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2012 Free Software
+   Copyright (C) 1999, 2002-2003, 2005, 2007, 2010-2013 Free Software
    Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/lib/putenv.c b/lib/putenv.c
index eb3fae3..2abc6ac 100644
--- a/lib/putenv.c
+++ b/lib/putenv.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1994, 1997-1998, 2000, 2003-2012 Free Software
+/* Copyright (C) 1991, 1994, 1997-1998, 2000, 2003-2013 Free Software
    Foundation, Inc.
 
    NOTE: The canonical source of this file is maintained with the GNU C
@@ -115,6 +115,37 @@ putenv (char *string)
 
   if (*ep == NULL)
     {
+#if HAVE__PUTENV
+      /* Rely on _putenv to allocate the new environment.  If other
+         parts of the application use _putenv, the !HAVE__PUTENV code
+         would fight over who owns the environ vector, causing a crash.  */
+      if (name_end[1])
+        return _putenv (string);
+      else
+        {
+          /* _putenv ("NAME=") unsets NAME, so invoke _putenv ("NAME=x")
+             to allocate the environ vector and then replace the new
+             entry with "NAME=".  */
+          int putenv_result, putenv_errno;
+          char *name_x = malloc (name_end - string + sizeof "=x");
+          if (!name_x)
+            return -1;
+          memcpy (name_x, string, name_end - string + 1);
+          name_x[name_end - string + 1] = 'x';
+          name_x[name_end - string + 2] = 0;
+          putenv_result = _putenv (name_x);
+          putenv_errno = errno;
+          for (ep = environ; *ep; ep++)
+            if (*ep == name_x)
+              {
+                *ep = string;
+                break;
+              }
+          free (name_x);
+          __set_errno (putenv_errno);
+          return putenv_result;
+        }
+#else
       static char **last_environ = NULL;
       char **new_environ = (char **) malloc ((size + 2) * sizeof (char *));
       if (new_environ == NULL)
@@ -126,6 +157,7 @@ putenv (char *string)
       free (last_environ);
       last_environ = new_environ;
       environ = new_environ;
+#endif
     }
   else
     *ep = string;
diff --git a/lib/raise.c b/lib/raise.c
index 0c3acbb..3720dfa 100644
--- a/lib/raise.c
+++ b/lib/raise.c
@@ -1,6 +1,6 @@
 /* Provide a non-threads replacement for the POSIX raise function.
 
-   Copyright (C) 2002-2003, 2005-2006, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2002-2003, 2005-2006, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -32,7 +32,7 @@
 # undef raise
 
 # if HAVE_MSVC_INVALID_PARAMETER_HANDLER
-static inline int
+static int
 raise_nothrow (int sig)
 {
   int result;
diff --git a/lib/read.c b/lib/read.c
index 9018bb5..155e6d1 100644
--- a/lib/read.c
+++ b/lib/read.c
@@ -1,5 +1,5 @@
 /* POSIX compatible read() function.
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2011.
 
    This program is free software: you can redistribute it and/or modify
@@ -34,7 +34,7 @@
 # undef read
 
 # if HAVE_MSVC_INVALID_PARAMETER_HANDLER
-static inline ssize_t
+static ssize_t
 read_nothrow (int fd, void *buf, size_t count)
 {
   ssize_t result;
diff --git a/lib/readlink.c b/lib/readlink.c
index c75d794..ce8a0e8 100644
--- a/lib/readlink.c
+++ b/lib/readlink.c
@@ -1,5 +1,5 @@
 /* Stub for readlink().
-   Copyright (C) 2003-2007, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2003-2007, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/recv.c b/lib/recv.c
index 7a5946a..aaa7d00 100644
--- a/lib/recv.c
+++ b/lib/recv.c
@@ -1,6 +1,6 @@
 /* recv.c --- wrappers for Windows recv function
 
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/recvfrom.c b/lib/recvfrom.c
index bfd97ac..3155071 100644
--- a/lib/recvfrom.c
+++ b/lib/recvfrom.c
@@ -1,6 +1,6 @@
 /* recvfrom.c --- wrappers for Windows recvfrom function
 
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/ref-add.sin b/lib/ref-add.sin
index 8c1a7d0..7cbdec5 100644
--- a/lib/ref-add.sin
+++ b/lib/ref-add.sin
@@ -1,6 +1,6 @@
 # Add this package to a list of references stored in a text file.
 #
-#   Copyright (C) 2000, 2009-2012 Free Software Foundation, Inc.
+#   Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc.
 #
 #   This program is free software; you can redistribute it and/or modify
 #   it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/ref-del.sin b/lib/ref-del.sin
index fd87588..cf7b492 100644
--- a/lib/ref-del.sin
+++ b/lib/ref-del.sin
@@ -1,6 +1,6 @@
 # Remove this package from a list of references stored in a text file.
 #
-#   Copyright (C) 2000, 2009-2012 Free Software Foundation, Inc.
+#   Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc.
 #
 #   This program is free software; you can redistribute it and/or modify
 #   it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/regcomp.c b/lib/regcomp.c
index 76947c2..b236f36 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -1,20 +1,21 @@
 /* Extended regular expression matching and search library.
-   Copyright (C) 2002-2012 Free Software Foundation, Inc.
+   Copyright (C) 2002-2013 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Isamu Hasegawa <address@hidden>.
 
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU Lesser General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
 
-   This program is distributed in the hope that it will be useful,
+   The GNU C Library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU Lesser General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
 
-   You should have received a copy of the GNU Lesser General Public License 
along
-   with this program; if not, see <http://www.gnu.org/licenses/>.  */
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern,
                                          size_t length, reg_syntax_t syntax);
@@ -93,20 +94,20 @@ static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE 
trans,
                                      bitset_t sbcset,
                                      re_charset_t *mbcset,
                                      Idx *char_class_alloc,
-                                     const unsigned char *class_name,
+                                     const char *class_name,
                                      reg_syntax_t syntax);
 #else  /* not RE_ENABLE_I18N */
 static reg_errcode_t build_equiv_class (bitset_t sbcset,
                                        const unsigned char *name);
 static reg_errcode_t build_charclass (RE_TRANSLATE_TYPE trans,
                                      bitset_t sbcset,
-                                     const unsigned char *class_name,
+                                     const char *class_name,
                                      reg_syntax_t syntax);
 #endif /* not RE_ENABLE_I18N */
 static bin_tree_t *build_charclass_op (re_dfa_t *dfa,
                                       RE_TRANSLATE_TYPE trans,
-                                      const unsigned char *class_name,
-                                      const unsigned char *extra,
+                                      const char *class_name,
+                                      const char *extra,
                                       bool non_match, reg_errcode_t *err);
 static bin_tree_t *create_tree (re_dfa_t *dfa,
                                bin_tree_t *left, bin_tree_t *right,
@@ -952,10 +953,10 @@ static void
 internal_function
 init_word_char (re_dfa_t *dfa)
 {
-  dfa->word_ops_used = 1;
   int i = 0;
   int j;
   int ch = 0;
+  dfa->word_ops_used = 1;
   if (BE (dfa->map_notascii == 0, 1))
     {
       bitset_word_t bits0 = 0x00000000;
@@ -2421,8 +2422,8 @@ parse_expression (re_string_t *regexp, regex_t *preg, 
re_token_t *token,
     case OP_WORD:
     case OP_NOTWORD:
       tree = build_charclass_op (dfa, regexp->trans,
-                                (const unsigned char *) "alnum",
-                                (const unsigned char *) "_",
+                                "alnum",
+                                "_",
                                 token->type == OP_NOTWORD, err);
       if (BE (*err != REG_NOERROR && tree == NULL, 0))
        return NULL;
@@ -2430,8 +2431,8 @@ parse_expression (re_string_t *regexp, regex_t *preg, 
re_token_t *token,
     case OP_SPACE:
     case OP_NOTSPACE:
       tree = build_charclass_op (dfa, regexp->trans,
-                                (const unsigned char *) "space",
-                                (const unsigned char *) "",
+                                "space",
+                                "",
                                 token->type == OP_NOTSPACE, err);
       if (BE (*err != REG_NOERROR && tree == NULL, 0))
        return NULL;
@@ -2711,7 +2712,6 @@ build_range_exp (const reg_syntax_t syntax,
     wchar_t wc;
     wint_t start_wc;
     wint_t end_wc;
-    wchar_t cmp_buf[6] = {L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'};
 
     start_ch = ((start_elem->type == SB_CHAR) ? start_elem->opr.ch
                : ((start_elem->type == COLL_SYM) ? start_elem->opr.name[0]
@@ -2725,11 +2725,7 @@ build_range_exp (const reg_syntax_t syntax,
              ? __btowc (end_ch) : end_elem->opr.wch);
     if (start_wc == WEOF || end_wc == WEOF)
       return REG_ECOLLATE;
-    cmp_buf[0] = start_wc;
-    cmp_buf[4] = end_wc;
-
-    if (BE ((syntax & RE_NO_EMPTY_RANGES)
-            && wcscoll (cmp_buf, cmp_buf + 4) > 0, 0))
+    else if (BE ((syntax & RE_NO_EMPTY_RANGES) && start_wc > end_wc, 0))
       return REG_ERANGE;
 
     /* Got valid collation sequence values, add them as a new entry.
@@ -2770,9 +2766,7 @@ build_range_exp (const reg_syntax_t syntax,
     /* Build the table for single byte characters.  */
     for (wc = 0; wc < SBC_MAX; ++wc)
       {
-       cmp_buf[2] = wc;
-       if (wcscoll (cmp_buf, cmp_buf + 2) <= 0
-           && wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0)
+       if (start_wc <= wc && wc <= end_wc)
          bitset_set (sbcset, wc);
       }
   }
@@ -2969,6 +2963,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, 
re_token_t *token,
              0))
        return REG_ERANGE;
 
+      /* FIXME: Implement rational ranges here, too.  */
       start_collseq = lookup_collation_sequence_value (start_elem);
       end_collseq = lookup_collation_sequence_value (end_elem);
       /* Check start/end collation sequence values.  */
@@ -3296,7 +3291,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, 
re_token_t *token,
 #ifdef RE_ENABLE_I18N
                                      mbcset, &char_class_alloc,
 #endif /* RE_ENABLE_I18N */
-                                     start_elem.opr.name, syntax);
+                                     (const char *) start_elem.opr.name,
+                                     syntax);
              if (BE (*err != REG_NOERROR, 0))
               goto parse_bracket_exp_free_return;
              break;
@@ -3576,14 +3572,14 @@ static reg_errcode_t
 #ifdef RE_ENABLE_I18N
 build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
                 re_charset_t *mbcset, Idx *char_class_alloc,
-                const unsigned char *class_name, reg_syntax_t syntax)
+                const char *class_name, reg_syntax_t syntax)
 #else /* not RE_ENABLE_I18N */
 build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
-                const unsigned char *class_name, reg_syntax_t syntax)
+                const char *class_name, reg_syntax_t syntax)
 #endif /* not RE_ENABLE_I18N */
 {
   int i;
-  const char *name = (const char *) class_name;
+  const char *name = class_name;
 
   /* In case of REG_ICASE "upper" and "lower" match the both of
      upper and lower cases.  */
@@ -3657,8 +3653,8 @@ build_charclass (RE_TRANSLATE_TYPE trans, bitset_t sbcset,
 
 static bin_tree_t *
 build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans,
-                   const unsigned char *class_name,
-                   const unsigned char *extra, bool non_match,
+                   const char *class_name,
+                   const char *extra, bool non_match,
                    reg_errcode_t *err)
 {
   re_bitset_ptr_t sbcset;
diff --git a/lib/regex.c b/lib/regex.c
index c578852..ca40e6e 100644
--- a/lib/regex.c
+++ b/lib/regex.c
@@ -1,20 +1,21 @@
 /* Extended regular expression matching and search library.
-   Copyright (C) 2002-2003, 2005-2006, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2002-2013 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Isamu Hasegawa <address@hidden>.
 
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU Lesser General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
 
-   This program is distributed in the hope that it will be useful,
+   The GNU C Library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU Lesser General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
 
-   You should have received a copy of the GNU Lesser General Public License 
along
-   with this program; if not, see <http://www.gnu.org/licenses/>.  */
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #ifndef _LIBC
 # include <config.h>
diff --git a/lib/regex.h b/lib/regex.h
index 07c1b3d..74645ca 100644
--- a/lib/regex.h
+++ b/lib/regex.h
@@ -1,21 +1,22 @@
 /* Definitions for data structures and routines for the regular
    expression library.
-   Copyright (C) 1985, 1989-1993, 1995-1998, 2000-2003, 2005-2012
-   Free Software Foundation, Inc.
+   Copyright (C) 1985, 1989-1993, 1995-1998, 2000-2003, 2005-2013 Free Software
+   Foundation, Inc.
    This file is part of the GNU C Library.
 
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU Lesser General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
 
-   This program is distributed in the hope that it will be useful,
+   The GNU C Library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU Lesser General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
 
-   You should have received a copy of the GNU Lesser General Public License 
along
-   with this program; if not, see <http://www.gnu.org/licenses/>.  */
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #ifndef _REGEX_H
 #define _REGEX_H 1
diff --git a/lib/regex_internal.c b/lib/regex_internal.c
index 71ee41e..e11ad3d 100644
--- a/lib/regex_internal.c
+++ b/lib/regex_internal.c
@@ -1,20 +1,21 @@
 /* Extended regular expression matching and search library.
-   Copyright (C) 2002-2012 Free Software Foundation, Inc.
+   Copyright (C) 2002-2013 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Isamu Hasegawa <address@hidden>.
 
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU Lesser General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
 
-   This program is distributed in the hope that it will be useful,
+   The GNU C Library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU Lesser General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
 
-   You should have received a copy of the GNU Lesser General Public License 
along
-   with this program; if not, see <http://www.gnu.org/licenses/>.  */
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 static void re_string_construct_common (const char *str, Idx len,
                                        re_string_t *pstr,
@@ -973,7 +974,7 @@ re_node_set_alloc (re_node_set *set, Idx size)
   set->alloc = size;
   set->nelem = 0;
   set->elems = re_malloc (Idx, size);
-  if (BE (set->elems == NULL, 0))
+  if (BE (set->elems == NULL, 0) && (MALLOC_0_IS_NONNULL || size != 0))
     return REG_ESPACE;
   return REG_NOERROR;
 }
@@ -1442,11 +1443,9 @@ re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
   dfa->nodes[dfa->nodes_len] = token;
   dfa->nodes[dfa->nodes_len].constraint = 0;
 #ifdef RE_ENABLE_I18N
-  {
-  int type = token.type;
   dfa->nodes[dfa->nodes_len].accept_mb =
-    (type == OP_PERIOD && dfa->mb_cur_max > 1) || type == COMPLEX_BRACKET;
-  }
+    ((token.type == OP_PERIOD && dfa->mb_cur_max > 1)
+     || token.type == COMPLEX_BRACKET);
 #endif
   dfa->nexts[dfa->nodes_len] = REG_MISSING;
   re_node_set_init_empty (dfa->edests + dfa->nodes_len);
@@ -1454,7 +1453,7 @@ re_dfa_add_node (re_dfa_t *dfa, re_token_t token)
   return dfa->nodes_len++;
 }
 
-static inline re_hashval_t
+static re_hashval_t
 internal_function
 calc_state_hash (const re_node_set *nodes, unsigned int context)
 {
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index fd331b1..fa93382 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -1,20 +1,21 @@
 /* Extended regular expression matching and search library.
-   Copyright (C) 2002-2012 Free Software Foundation, Inc.
+   Copyright (C) 2002-2013 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Isamu Hasegawa <address@hidden>.
 
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU Lesser General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
 
-   This program is distributed in the hope that it will be useful,
+   The GNU C Library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU Lesser General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
 
-   You should have received a copy of the GNU Lesser General Public License 
along
-   with this program; if not, see <http://www.gnu.org/licenses/>.  */
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #ifndef _REGEX_INTERNAL_H
 #define _REGEX_INTERNAL_H 1
@@ -26,9 +27,6 @@
 #include <string.h>
 
 #include <langinfo.h>
-#ifndef _LIBC
-# include "localcharset.h"
-#endif
 #include <locale.h>
 #include <wchar.h>
 #include <wctype.h>
@@ -37,7 +35,6 @@
 #if defined _LIBC
 # include <bits/libc-lock.h>
 #else
-# define __libc_lock_define(CLASS,NAME)
 # define __libc_lock_init(NAME) do { } while (0)
 # define __libc_lock_lock(NAME) do { } while (0)
 # define __libc_lock_unlock(NAME) do { } while (0)
@@ -63,7 +60,7 @@
 # ifdef _LIBC
 #  undef gettext
 #  define gettext(msgid) \
-  INTUSE(__dcgettext) (_libc_intl_domainname, msgid, LC_MESSAGES)
+  __dcgettext (_libc_intl_domainname, msgid, LC_MESSAGES)
 # endif
 #else
 # define gettext(msgid) (msgid)
@@ -83,9 +80,6 @@
 # define BE(expr, val) __builtin_expect (expr, val)
 #else
 # define BE(expr, val) (expr)
-# ifdef _LIBC
-#  define inline
-# endif
 #endif
 
 /* Number of ASCII characters.  */
@@ -102,6 +96,8 @@
 
 /* Rename to standard API for using out of glibc.  */
 #ifndef _LIBC
+# undef __wctype
+# undef __iswctype
 # define __wctype wctype
 # define __iswctype iswctype
 # define __btowc btowc
@@ -449,7 +445,9 @@ static unsigned int re_string_context_at (const re_string_t 
*input, Idx idx,
 #define re_string_skip_bytes(pstr,idx) ((pstr)->cur_idx += (idx))
 #define re_string_set_index(pstr,idx) ((pstr)->cur_idx = (idx))
 
-#include <alloca.h>
+#if defined _LIBC || HAVE_ALLOCA
+# include <alloca.h>
+#endif
 
 #ifndef _LIBC
 # if HAVE_ALLOCA
@@ -466,6 +464,12 @@ static unsigned int re_string_context_at (const 
re_string_t *input, Idx idx,
 # endif
 #endif
 
+#ifdef _LIBC
+# define MALLOC_0_IS_NONNULL 1
+#elif !defined MALLOC_0_IS_NONNULL
+# define MALLOC_0_IS_NONNULL 0
+#endif
+
 #ifndef MAX
 # define MAX(a,b) ((a) < (b) ? (b) : (a))
 #endif
@@ -696,7 +700,9 @@ struct re_dfa_t
 #ifdef DEBUG
   char* re_str;
 #endif
+#ifdef _LIBC
   __libc_lock_define (, lock)
+#endif
 };
 
 #define re_node_set_init_empty(set) memset (set, '\0', sizeof (re_node_set))
@@ -727,33 +733,33 @@ typedef struct
 } bracket_elem_t;
 
 
-/* Inline functions for bitset_t operation.  */
+/* Functions for bitset_t operation.  */
 
-static inline void
+static void
 bitset_set (bitset_t set, Idx i)
 {
   set[i / BITSET_WORD_BITS] |= (bitset_word_t) 1 << i % BITSET_WORD_BITS;
 }
 
-static inline void
+static void
 bitset_clear (bitset_t set, Idx i)
 {
   set[i / BITSET_WORD_BITS] &= ~ ((bitset_word_t) 1 << i % BITSET_WORD_BITS);
 }
 
-static inline bool
+static bool
 bitset_contain (const bitset_t set, Idx i)
 {
   return (set[i / BITSET_WORD_BITS] >> i % BITSET_WORD_BITS) & 1;
 }
 
-static inline void
+static void
 bitset_empty (bitset_t set)
 {
   memset (set, '\0', sizeof (bitset_t));
 }
 
-static inline void
+static void
 bitset_set_all (bitset_t set)
 {
   memset (set, -1, sizeof (bitset_word_t) * (SBC_MAX / BITSET_WORD_BITS));
@@ -762,13 +768,13 @@ bitset_set_all (bitset_t set)
       ((bitset_word_t) 1 << SBC_MAX % BITSET_WORD_BITS) - 1;
 }
 
-static inline void
+static void
 bitset_copy (bitset_t dest, const bitset_t src)
 {
   memcpy (dest, src, sizeof (bitset_t));
 }
 
-static inline void
+static void
 bitset_not (bitset_t set)
 {
   int bitset_i;
@@ -780,7 +786,7 @@ bitset_not (bitset_t set)
        & ~set[BITSET_WORDS - 1]);
 }
 
-static inline void
+static void
 bitset_merge (bitset_t dest, const bitset_t src)
 {
   int bitset_i;
@@ -788,7 +794,7 @@ bitset_merge (bitset_t dest, const bitset_t src)
     dest[bitset_i] |= src[bitset_i];
 }
 
-static inline void
+static void
 bitset_mask (bitset_t dest, const bitset_t src)
 {
   int bitset_i;
@@ -797,8 +803,8 @@ bitset_mask (bitset_t dest, const bitset_t src)
 }
 
 #ifdef RE_ENABLE_I18N
-/* Inline functions for re_string.  */
-static inline int
+/* Functions for re_string.  */
+static int
 internal_function __attribute ((pure))
 re_string_char_size_at (const re_string_t *pstr, Idx idx)
 {
@@ -811,7 +817,7 @@ re_string_char_size_at (const re_string_t *pstr, Idx idx)
   return byte_idx;
 }
 
-static inline wint_t
+static wint_t
 internal_function __attribute ((pure))
 re_string_wchar_at (const re_string_t *pstr, Idx idx)
 {
diff --git a/lib/regexec.c b/lib/regexec.c
index 13c3f15..1bd1640 100644
--- a/lib/regexec.c
+++ b/lib/regexec.c
@@ -1,20 +1,21 @@
 /* Extended regular expression matching and search library.
-   Copyright (C) 2002-2012 Free Software Foundation, Inc.
+   Copyright (C) 2002-2013 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Isamu Hasegawa <address@hidden>.
 
-   This program is free software; you can redistribute it and/or modify
-   it under the terms of the GNU Lesser General Public License as published by
-   the Free Software Foundation; either version 2, or (at your option)
-   any later version.
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
 
-   This program is distributed in the hope that it will be useful,
+   The GNU C Library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU Lesser General Public License for more details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
 
-   You should have received a copy of the GNU Lesser General Public License 
along
-   with this program; if not, see <http://www.gnu.org/licenses/>.  */
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags,
                                     Idx n) internal_function;
@@ -198,7 +199,7 @@ static Idx group_nodes_into_DFAstates (const re_dfa_t *dfa,
 static bool check_node_accept (const re_match_context_t *mctx,
                               const re_token_t *node, Idx idx)
      internal_function;
-static reg_errcode_t extend_buffers (re_match_context_t *mctx)
+static reg_errcode_t extend_buffers (re_match_context_t *mctx, int min_len)
      internal_function;
 
 /* Entry point for POSIX code.  */
@@ -1175,7 +1176,7 @@ check_matching (re_match_context_t *mctx, bool 
fl_longest_match,
          || (BE (next_char_idx >= mctx->input.valid_len, 0)
              && mctx->input.valid_len < mctx->input.len))
        {
-         err = extend_buffers (mctx);
+         err = extend_buffers (mctx, next_char_idx + 1);
          if (BE (err != REG_NOERROR, 0))
            {
              assert (err == REG_ESPACE);
@@ -1755,7 +1756,7 @@ clean_state_log_if_needed (re_match_context_t *mctx, Idx 
next_state_log_idx)
          && mctx->input.valid_len < mctx->input.len))
     {
       reg_errcode_t err;
-      err = extend_buffers (mctx);
+      err = extend_buffers (mctx, next_state_log_idx + 1);
       if (BE (err != REG_NOERROR, 0))
        return err;
     }
@@ -2812,7 +2813,7 @@ get_subexp (re_match_context_t *mctx, Idx bkref_node, Idx 
bkref_str_idx)
                  if (bkref_str_off >= mctx->input.len)
                    break;
 
-                 err = extend_buffers (mctx);
+                 err = extend_buffers (mctx, bkref_str_off + 1);
                  if (BE (err != REG_NOERROR, 0))
                    return err;
 
@@ -3935,6 +3936,7 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx 
node_idx,
                in_collseq = find_collation_sequence_value (pin, elem_len);
            }
          /* match with range expression?  */
+         /* FIXME: Implement rational ranges here, too.  */
          for (i = 0; i < cset->nranges; ++i)
            if (cset->range_starts[i] <= in_collseq
                && in_collseq <= cset->range_ends[i])
@@ -3986,18 +3988,9 @@ check_node_accept_bytes (const re_dfa_t *dfa, Idx 
node_idx,
 # endif /* _LIBC */
        {
          /* match with range expression?  */
-#if __GNUC__ >= 2 && ! (__STDC_VERSION__ < 199901L && defined __STRICT_ANSI__)
-         wchar_t cmp_buf[] = {L'\0', L'\0', wc, L'\0', L'\0', L'\0'};
-#else
-         wchar_t cmp_buf[] = {L'\0', L'\0', L'\0', L'\0', L'\0', L'\0'};
-         cmp_buf[2] = wc;
-#endif
          for (i = 0; i < cset->nranges; ++i)
            {
-             cmp_buf[0] = cset->range_starts[i];
-             cmp_buf[4] = cset->range_ends[i];
-             if (wcscoll (cmp_buf, cmp_buf + 2) <= 0
-                 && wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0)
+             if (cset->range_starts[i] <= wc && wc <= cset->range_ends[i])
                {
                  match_len = char_len;
                  goto check_node_accept_bytes_match;
@@ -4135,7 +4128,7 @@ check_node_accept (const re_match_context_t *mctx, const 
re_token_t *node,
 
 static reg_errcode_t
 internal_function __attribute_warn_unused_result__
-extend_buffers (re_match_context_t *mctx)
+extend_buffers (re_match_context_t *mctx, int min_len)
 {
   reg_errcode_t ret;
   re_string_t *pstr = &mctx->input;
@@ -4145,8 +4138,10 @@ extend_buffers (re_match_context_t *mctx)
           <= pstr->bufs_len, 0))
     return REG_ESPACE;
 
-  /* Double the lengths of the buffers.  */
-  ret = re_string_realloc_buffers (pstr, MIN (pstr->len, pstr->bufs_len * 2));
+  /* Double the lengths of the buffers, but allocate at least MIN_LEN.  */
+  ret = re_string_realloc_buffers (pstr,
+                                  MAX (min_len,
+                                       MIN (pstr->len, pstr->bufs_len * 2)));
   if (BE (ret != REG_NOERROR, 0))
     return ret;
 
diff --git a/lib/rename.c b/lib/rename.c
index 547a6a2..eceadec 100644
--- a/lib/rename.c
+++ b/lib/rename.c
@@ -1,6 +1,6 @@
 /* Work around rename bugs in some systems.
 
-   Copyright (C) 2001-2003, 2005-2006, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2001-2003, 2005-2006, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/rmdir.c b/lib/rmdir.c
index 0b53626..f18acbe 100644
--- a/lib/rmdir.c
+++ b/lib/rmdir.c
@@ -1,6 +1,6 @@
 /* Work around rmdir bugs.
 
-   Copyright (C) 1988, 1990, 1999, 2003-2006, 2009-2012 Free Software
+   Copyright (C) 1988, 1990, 1999, 2003-2006, 2009-2013 Free Software
    Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/round.c b/lib/round.c
index 53dfe84..4d4e69b 100644
--- a/lib/round.c
+++ b/lib/round.c
@@ -1,5 +1,5 @@
 /* Round toward nearest, breaking ties away from zero.
-   Copyright (C) 2007, 2010-2012 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2010-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/safe-read.c b/lib/safe-read.c
index d2d85c7..39490ab 100644
--- a/lib/safe-read.c
+++ b/lib/safe-read.c
@@ -1,6 +1,6 @@
 /* An interface to read and write that retries after interrupts.
 
-   Copyright (C) 1993-1994, 1998, 2002-2006, 2009-2012 Free Software
+   Copyright (C) 1993-1994, 1998, 2002-2006, 2009-2013 Free Software
    Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/safe-read.h b/lib/safe-read.h
index dc73922..91a86c6 100644
--- a/lib/safe-read.h
+++ b/lib/safe-read.h
@@ -1,5 +1,5 @@
 /* An interface to read() that retries after interrupts.
-   Copyright (C) 2002, 2006, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2006, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/safe-write.c b/lib/safe-write.c
index cd42722..71f2f3d 100644
--- a/lib/safe-write.c
+++ b/lib/safe-write.c
@@ -1,5 +1,5 @@
 /* An interface to write that retries after interrupts.
-   Copyright (C) 2002, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/safe-write.h b/lib/safe-write.h
index 3a7f509..779f5d5 100644
--- a/lib/safe-write.h
+++ b/lib/safe-write.h
@@ -1,5 +1,5 @@
 /* An interface to write() that retries after interrupts.
-   Copyright (C) 2002, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/same-inode.h b/lib/same-inode.h
index 7ce286d..94fe3e2 100644
--- a/lib/same-inode.h
+++ b/lib/same-inode.h
@@ -1,6 +1,6 @@
 /* Determine whether two stat buffers refer to the same file.
 
-   Copyright (C) 2006, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/select.c b/lib/select.c
new file mode 100644
index 0000000..13ca150
--- /dev/null
+++ b/lib/select.c
@@ -0,0 +1,547 @@
+/* Emulation for select(2)
+   Contributed by Paolo Bonzini.
+
+   Copyright 2008-2013 Free Software Foundation, Inc.
+
+   This file is part of gnulib.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License 
along
+   with this program; if not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+#include <alloca.h>
+#include <assert.h>
+
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+/* Native Windows.  */
+
+#include <sys/types.h>
+#include <errno.h>
+#include <limits.h>
+
+#include <winsock2.h>
+#include <windows.h>
+#include <io.h>
+#include <stdio.h>
+#include <conio.h>
+#include <time.h>
+
+/* Get the overridden 'struct timeval'.  */
+#include <sys/time.h>
+
+#include "msvc-nothrow.h"
+
+#undef select
+
+struct bitset {
+  unsigned char in[FD_SETSIZE / CHAR_BIT];
+  unsigned char out[FD_SETSIZE / CHAR_BIT];
+};
+
+/* Declare data structures for ntdll functions.  */
+typedef struct _FILE_PIPE_LOCAL_INFORMATION {
+  ULONG NamedPipeType;
+  ULONG NamedPipeConfiguration;
+  ULONG MaximumInstances;
+  ULONG CurrentInstances;
+  ULONG InboundQuota;
+  ULONG ReadDataAvailable;
+  ULONG OutboundQuota;
+  ULONG WriteQuotaAvailable;
+  ULONG NamedPipeState;
+  ULONG NamedPipeEnd;
+} FILE_PIPE_LOCAL_INFORMATION, *PFILE_PIPE_LOCAL_INFORMATION;
+
+typedef struct _IO_STATUS_BLOCK
+{
+  union {
+    DWORD Status;
+    PVOID Pointer;
+  } u;
+  ULONG_PTR Information;
+} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
+
+typedef enum _FILE_INFORMATION_CLASS {
+  FilePipeLocalInformation = 24
+} FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
+
+typedef DWORD (WINAPI *PNtQueryInformationFile)
+         (HANDLE, IO_STATUS_BLOCK *, VOID *, ULONG, FILE_INFORMATION_CLASS);
+
+#ifndef PIPE_BUF
+#define PIPE_BUF        512
+#endif
+
+/* Optimized test whether a HANDLE refers to a console.
+   See <http://lists.gnu.org/archive/html/bug-gnulib/2009-08/msg00065.html>.  
*/
+#define IsConsoleHandle(h) (((intptr_t) (h) & 3) == 3)
+
+static BOOL
+IsSocketHandle (HANDLE h)
+{
+  WSANETWORKEVENTS ev;
+
+  if (IsConsoleHandle (h))
+    return FALSE;
+
+  /* Under Wine, it seems that getsockopt returns 0 for pipes too.
+     WSAEnumNetworkEvents instead distinguishes the two correctly.  */
+  ev.lNetworkEvents = 0xDEADBEEF;
+  WSAEnumNetworkEvents ((SOCKET) h, NULL, &ev);
+  return ev.lNetworkEvents != 0xDEADBEEF;
+}
+
+/* Compute output fd_sets for libc descriptor FD (whose Windows handle is
+   H).  */
+
+static int
+windows_poll_handle (HANDLE h, int fd,
+                     struct bitset *rbits,
+                     struct bitset *wbits,
+                     struct bitset *xbits)
+{
+  BOOL read, write, except;
+  int i, ret;
+  INPUT_RECORD *irbuffer;
+  DWORD avail, nbuffer;
+  BOOL bRet;
+  IO_STATUS_BLOCK iosb;
+  FILE_PIPE_LOCAL_INFORMATION fpli;
+  static PNtQueryInformationFile NtQueryInformationFile;
+  static BOOL once_only;
+
+  read = write = except = FALSE;
+  switch (GetFileType (h))
+    {
+    case FILE_TYPE_DISK:
+      read = TRUE;
+      write = TRUE;
+      break;
+
+    case FILE_TYPE_PIPE:
+      if (!once_only)
+        {
+          NtQueryInformationFile = (PNtQueryInformationFile)
+            GetProcAddress (GetModuleHandle ("ntdll.dll"),
+                            "NtQueryInformationFile");
+          once_only = TRUE;
+        }
+
+      if (PeekNamedPipe (h, NULL, 0, NULL, &avail, NULL) != 0)
+        {
+          if (avail)
+            read = TRUE;
+        }
+      else if (GetLastError () == ERROR_BROKEN_PIPE)
+        ;
+
+      else
+        {
+          /* It was the write-end of the pipe.  Check if it is writable.
+             If NtQueryInformationFile fails, optimistically assume the pipe is
+             writable.  This could happen on Windows 9x, where
+             NtQueryInformationFile is not available, or if we inherit a pipe
+             that doesn't permit FILE_READ_ATTRIBUTES access on the write end
+             (I think this should not happen since Windows XP SP2; WINE seems
+             fine too).  Otherwise, ensure that enough space is available for
+             atomic writes.  */
+          memset (&iosb, 0, sizeof (iosb));
+          memset (&fpli, 0, sizeof (fpli));
+
+          if (!NtQueryInformationFile
+              || NtQueryInformationFile (h, &iosb, &fpli, sizeof (fpli),
+                                         FilePipeLocalInformation)
+              || fpli.WriteQuotaAvailable >= PIPE_BUF
+              || (fpli.OutboundQuota < PIPE_BUF &&
+                  fpli.WriteQuotaAvailable == fpli.OutboundQuota))
+            write = TRUE;
+        }
+      break;
+
+    case FILE_TYPE_CHAR:
+      write = TRUE;
+      if (!(rbits->in[fd / CHAR_BIT] & (1 << (fd & (CHAR_BIT - 1)))))
+        break;
+
+      ret = WaitForSingleObject (h, 0);
+      if (ret == WAIT_OBJECT_0)
+        {
+          if (!IsConsoleHandle (h))
+            {
+              read = TRUE;
+              break;
+            }
+
+          nbuffer = avail = 0;
+          bRet = GetNumberOfConsoleInputEvents (h, &nbuffer);
+
+          /* Screen buffers handles are filtered earlier.  */
+          assert (bRet);
+          if (nbuffer == 0)
+            {
+              except = TRUE;
+              break;
+            }
+
+          irbuffer = (INPUT_RECORD *) alloca (nbuffer * sizeof (INPUT_RECORD));
+          bRet = PeekConsoleInput (h, irbuffer, nbuffer, &avail);
+          if (!bRet || avail == 0)
+            {
+              except = TRUE;
+              break;
+            }
+
+          for (i = 0; i < avail; i++)
+            if (irbuffer[i].EventType == KEY_EVENT)
+              read = TRUE;
+        }
+      break;
+
+    default:
+      ret = WaitForSingleObject (h, 0);
+      write = TRUE;
+      if (ret == WAIT_OBJECT_0)
+        read = TRUE;
+
+      break;
+    }
+
+  ret = 0;
+  if (read && (rbits->in[fd / CHAR_BIT] & (1 << (fd & (CHAR_BIT - 1)))))
+    {
+      rbits->out[fd / CHAR_BIT] |= (1 << (fd & (CHAR_BIT - 1)));
+      ret++;
+    }
+
+  if (write && (wbits->in[fd / CHAR_BIT] & (1 << (fd & (CHAR_BIT - 1)))))
+    {
+      wbits->out[fd / CHAR_BIT] |= (1 << (fd & (CHAR_BIT - 1)));
+      ret++;
+    }
+
+  if (except && (xbits->in[fd / CHAR_BIT] & (1 << (fd & (CHAR_BIT - 1)))))
+    {
+      xbits->out[fd / CHAR_BIT] |= (1 << (fd & (CHAR_BIT - 1)));
+      ret++;
+    }
+
+  return ret;
+}
+
+int
+rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds,
+            struct timeval *timeout)
+#undef timeval
+{
+  static struct timeval tv0;
+  static HANDLE hEvent;
+  HANDLE h, handle_array[FD_SETSIZE + 2];
+  fd_set handle_rfds, handle_wfds, handle_xfds;
+  struct bitset rbits, wbits, xbits;
+  unsigned char anyfds_in[FD_SETSIZE / CHAR_BIT];
+  DWORD ret, wait_timeout, nhandles, nsock, nbuffer;
+  MSG msg;
+  int i, fd, rc;
+
+  if (nfds > FD_SETSIZE)
+    nfds = FD_SETSIZE;
+
+  if (!timeout)
+    wait_timeout = INFINITE;
+  else
+    {
+      wait_timeout = timeout->tv_sec * 1000 + timeout->tv_usec / 1000;
+
+      /* select is also used as a portable usleep.  */
+      if (!rfds && !wfds && !xfds)
+        {
+          Sleep (wait_timeout);
+          return 0;
+        }
+    }
+
+  if (!hEvent)
+    hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
+
+  handle_array[0] = hEvent;
+  nhandles = 1;
+  nsock = 0;
+
+  /* Copy descriptors to bitsets.  At the same time, eliminate
+     bits in the "wrong" direction for console input buffers
+     and screen buffers, because screen buffers are waitable
+     and they will block until a character is available.  */
+  memset (&rbits, 0, sizeof (rbits));
+  memset (&wbits, 0, sizeof (wbits));
+  memset (&xbits, 0, sizeof (xbits));
+  memset (anyfds_in, 0, sizeof (anyfds_in));
+  if (rfds)
+    for (i = 0; i < rfds->fd_count; i++)
+      {
+        fd = rfds->fd_array[i];
+        h = (HANDLE) _get_osfhandle (fd);
+        if (IsConsoleHandle (h)
+            && !GetNumberOfConsoleInputEvents (h, &nbuffer))
+          continue;
+
+        rbits.in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
+        anyfds_in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
+      }
+  else
+    rfds = (fd_set *) alloca (sizeof (fd_set));
+
+  if (wfds)
+    for (i = 0; i < wfds->fd_count; i++)
+      {
+        fd = wfds->fd_array[i];
+        h = (HANDLE) _get_osfhandle (fd);
+        if (IsConsoleHandle (h)
+            && GetNumberOfConsoleInputEvents (h, &nbuffer))
+          continue;
+
+        wbits.in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
+        anyfds_in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
+      }
+  else
+    wfds = (fd_set *) alloca (sizeof (fd_set));
+
+  if (xfds)
+    for (i = 0; i < xfds->fd_count; i++)
+      {
+        fd = xfds->fd_array[i];
+        xbits.in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
+        anyfds_in[fd / CHAR_BIT] |= 1 << (fd & (CHAR_BIT - 1));
+      }
+  else
+    xfds = (fd_set *) alloca (sizeof (fd_set));
+
+  /* Zero all the fd_sets, including the application's.  */
+  FD_ZERO (rfds);
+  FD_ZERO (wfds);
+  FD_ZERO (xfds);
+  FD_ZERO (&handle_rfds);
+  FD_ZERO (&handle_wfds);
+  FD_ZERO (&handle_xfds);
+
+  /* Classify handles.  Create fd sets for sockets, poll the others. */
+  for (i = 0; i < nfds; i++)
+    {
+      if ((anyfds_in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) == 0)
+        continue;
+
+      h = (HANDLE) _get_osfhandle (i);
+      if (!h)
+        {
+          errno = EBADF;
+          return -1;
+        }
+
+      if (IsSocketHandle (h))
+        {
+          int requested = FD_CLOSE;
+
+          /* See above; socket handles are mapped onto select, but we
+             need to map descriptors to handles.  */
+          if (rbits.in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
+            {
+              requested |= FD_READ | FD_ACCEPT;
+              FD_SET ((SOCKET) h, rfds);
+              FD_SET ((SOCKET) h, &handle_rfds);
+            }
+          if (wbits.in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
+            {
+              requested |= FD_WRITE | FD_CONNECT;
+              FD_SET ((SOCKET) h, wfds);
+              FD_SET ((SOCKET) h, &handle_wfds);
+            }
+          if (xbits.in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
+            {
+              requested |= FD_OOB;
+              FD_SET ((SOCKET) h, xfds);
+              FD_SET ((SOCKET) h, &handle_xfds);
+            }
+
+          WSAEventSelect ((SOCKET) h, hEvent, requested);
+          nsock++;
+        }
+      else
+        {
+          handle_array[nhandles++] = h;
+
+          /* Poll now.  If we get an event, do not wait below.  */
+          if (wait_timeout != 0
+              && windows_poll_handle (h, i, &rbits, &wbits, &xbits))
+            wait_timeout = 0;
+        }
+    }
+
+  /* Place a sentinel at the end of the array.  */
+  handle_array[nhandles] = NULL;
+
+restart:
+  if (wait_timeout == 0 || nsock == 0)
+    rc = 0;
+  else
+    {
+      /* See if we need to wait in the loop below.  If any select is ready,
+         do MsgWaitForMultipleObjects anyway to dispatch messages, but
+         no need to call select again.  */
+      rc = select (0, &handle_rfds, &handle_wfds, &handle_xfds, &tv0);
+      if (rc == 0)
+        {
+          /* Restore the fd_sets for the other select we do below.  */
+          memcpy (&handle_rfds, rfds, sizeof (fd_set));
+          memcpy (&handle_wfds, wfds, sizeof (fd_set));
+          memcpy (&handle_xfds, xfds, sizeof (fd_set));
+        }
+      else
+        wait_timeout = 0;
+    }
+
+  for (;;)
+    {
+      ret = MsgWaitForMultipleObjects (nhandles, handle_array, FALSE,
+                                       wait_timeout, QS_ALLINPUT);
+
+      if (ret == WAIT_OBJECT_0 + nhandles)
+        {
+          /* new input of some other kind */
+          BOOL bRet;
+          while ((bRet = PeekMessage (&msg, NULL, 0, 0, PM_REMOVE)) != 0)
+            {
+              TranslateMessage (&msg);
+              DispatchMessage (&msg);
+            }
+        }
+      else
+        break;
+    }
+
+  /* If we haven't done it yet, check the status of the sockets.  */
+  if (rc == 0 && nsock > 0)
+    rc = select (0, &handle_rfds, &handle_wfds, &handle_xfds, &tv0);
+
+  if (nhandles > 1)
+    {
+      /* Count results that are not counted in the return value of select.  */
+      nhandles = 1;
+      for (i = 0; i < nfds; i++)
+        {
+          if ((anyfds_in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) == 0)
+            continue;
+
+          h = (HANDLE) _get_osfhandle (i);
+          if (h == handle_array[nhandles])
+            {
+              /* Not a socket.  */
+              nhandles++;
+              windows_poll_handle (h, i, &rbits, &wbits, &xbits);
+              if (rbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))
+                  || wbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))
+                  || xbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
+                rc++;
+            }
+        }
+
+      if (rc == 0 && wait_timeout == INFINITE)
+        {
+          /* Sleep 1 millisecond to avoid busy wait and retry with the
+             original fd_sets.  */
+          memcpy (&handle_rfds, rfds, sizeof (fd_set));
+          memcpy (&handle_wfds, wfds, sizeof (fd_set));
+          memcpy (&handle_xfds, xfds, sizeof (fd_set));
+          SleepEx (1, TRUE);
+          goto restart;
+        }
+    }
+
+  /* Now fill in the results.  */
+  FD_ZERO (rfds);
+  FD_ZERO (wfds);
+  FD_ZERO (xfds);
+  nhandles = 1;
+  for (i = 0; i < nfds; i++)
+    {
+      if ((anyfds_in[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1)))) == 0)
+        continue;
+
+      h = (HANDLE) _get_osfhandle (i);
+      if (h != handle_array[nhandles])
+        {
+          /* Perform handle->descriptor mapping.  */
+          WSAEventSelect ((SOCKET) h, NULL, 0);
+          if (FD_ISSET (h, &handle_rfds))
+            FD_SET (i, rfds);
+          if (FD_ISSET (h, &handle_wfds))
+            FD_SET (i, wfds);
+          if (FD_ISSET (h, &handle_xfds))
+            FD_SET (i, xfds);
+        }
+      else
+        {
+          /* Not a socket.  */
+          nhandles++;
+          if (rbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
+            FD_SET (i, rfds);
+          if (wbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
+            FD_SET (i, wfds);
+          if (xbits.out[i / CHAR_BIT] & (1 << (i & (CHAR_BIT - 1))))
+            FD_SET (i, xfds);
+        }
+    }
+
+  return rc;
+}
+
+#else /* ! Native Windows.  */
+
+#include <sys/select.h>
+#include <stddef.h> /* NULL */
+#include <errno.h>
+#include <unistd.h>
+
+#undef select
+
+int
+rpl_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds,
+            struct timeval *timeout)
+{
+  int i;
+
+  /* FreeBSD 8.2 has a bug: it does not always detect invalid fds.  */
+  if (nfds < 0 || nfds > FD_SETSIZE)
+    {
+      errno = EINVAL;
+      return -1;
+    }
+  for (i = 0; i < nfds; i++)
+    {
+      if (((rfds && FD_ISSET (i, rfds))
+           || (wfds && FD_ISSET (i, wfds))
+           || (xfds && FD_ISSET (i, xfds)))
+          && dup2 (i, i) != i)
+        return -1;
+    }
+
+  /* Interix 3.5 has a bug: it does not support nfds == 0.  */
+  if (nfds == 0)
+    {
+      nfds = 1;
+      rfds = NULL;
+      wfds = NULL;
+      xfds = NULL;
+    }
+  return select (nfds, rfds, wfds, xfds, timeout);
+}
+
+#endif
diff --git a/lib/send.c b/lib/send.c
index 64d0e8d..3e76ce1 100644
--- a/lib/send.c
+++ b/lib/send.c
@@ -1,6 +1,6 @@
 /* send.c --- wrappers for Windows send function
 
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/sendto.c b/lib/sendto.c
index 7a8e994..2154582 100644
--- a/lib/sendto.c
+++ b/lib/sendto.c
@@ -1,6 +1,6 @@
 /* sendto.c --- wrappers for Windows sendto function
 
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/setenv.c b/lib/setenv.c
index 75f423f..8076c54 100644
--- a/lib/setenv.c
+++ b/lib/setenv.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1995-2003, 2005-2012 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1995-2003, 2005-2013 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    This program is free software: you can redistribute it and/or modify
@@ -15,14 +15,14 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #if !_LIBC
+/* Don't use __attribute__ __nonnull__ in this compilation unit.  Otherwise gcc
+   optimizes away the name == NULL test below.  */
+# define _GL_ARG_NONNULL(params)
+
 # define _GL_USE_STDLIB_ALLOC 1
 # include <config.h>
 #endif
 
-/* Don't use __attribute__ __nonnull__ in this compilation unit.  Otherwise gcc
-   optimizes away the name == NULL test below.  */
-#define _GL_ARG_NONNULL(params)
-
 #include <alloca.h>
 
 /* Specification.  */
diff --git a/lib/setsockopt.c b/lib/setsockopt.c
index 07e9023..7a50835 100644
--- a/lib/setsockopt.c
+++ b/lib/setsockopt.c
@@ -1,6 +1,6 @@
 /* setsockopt.c --- wrappers for Windows setsockopt function
 
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/shutdown.c b/lib/shutdown.c
index 1e646a9..2f5fc54 100644
--- a/lib/shutdown.c
+++ b/lib/shutdown.c
@@ -1,6 +1,6 @@
 /* shutdown.c --- wrappers for Windows shutdown function
 
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/signal.in.h b/lib/signal.in.h
index 627ae17..6f96f0d 100644
--- a/lib/signal.in.h
+++ b/lib/signal.in.h
@@ -1,6 +1,6 @@
 /* A GNU-like <signal.h>.
 
-   Copyright (C) 2006-2012 Free Software Foundation, Inc.
+   Copyright (C) 2006-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/size_max.h b/lib/size_max.h
index 60d50f1..20fb1b7 100644
--- a/lib/size_max.h
+++ b/lib/size_max.h
@@ -1,5 +1,5 @@
 /* size_max.h -- declare SIZE_MAX through system headers
-   Copyright (C) 2005-2006, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2005-2006, 2009-2013 Free Software Foundation, Inc.
    Written by Simon Josefsson.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/lib/snprintf.c b/lib/snprintf.c
index eb27f5d..3cccf48 100644
--- a/lib/snprintf.c
+++ b/lib/snprintf.c
@@ -1,5 +1,5 @@
 /* Formatted output to strings.
-   Copyright (C) 2004, 2006-2012 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2006-2013 Free Software Foundation, Inc.
    Written by Simon Josefsson and Paul Eggert.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/lib/socket.c b/lib/socket.c
index 24f16c9..17fecc4 100644
--- a/lib/socket.c
+++ b/lib/socket.c
@@ -1,6 +1,6 @@
 /* socket.c --- wrappers for Windows socket function
 
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/sockets.c b/lib/sockets.c
index 635479a..d4652a2 100644
--- a/lib/sockets.c
+++ b/lib/sockets.c
@@ -1,6 +1,6 @@
 /* sockets.c --- wrappers for Windows socket functions
 
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/sockets.h b/lib/sockets.h
index 35d6923..4eb4dcb 100644
--- a/lib/sockets.h
+++ b/lib/sockets.h
@@ -1,6 +1,6 @@
 /* sockets.h - wrappers for Windows socket functions
 
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/stat-time.h b/lib/stat-time.h
index daf2ca6..a3dff54 100644
--- a/lib/stat-time.h
+++ b/lib/stat-time.h
@@ -1,6 +1,6 @@
 /* stat-related time functions.
 
-   Copyright (C) 2005, 2007, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2007, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/stat.c b/lib/stat.c
index f46e31d..c42962b 100644
--- a/lib/stat.c
+++ b/lib/stat.c
@@ -1,5 +1,5 @@
 /* Work around platform bugs in stat.
-   Copyright (C) 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2009-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -42,7 +42,7 @@
 # endif
 #endif
 
-static inline int
+static int
 orig_stat (const char *filename, struct stat *buf)
 {
   return stat (filename, buf);
diff --git a/lib/stdalign.in.h b/lib/stdalign.in.h
index e043871..d9b2eec 100644
--- a/lib/stdalign.in.h
+++ b/lib/stdalign.in.h
@@ -1,6 +1,6 @@
 /* A substitute for ISO C11 <stdalign.h>.
 
-   Copyright 2011-2012 Free Software Foundation, Inc.
+   Copyright 2011-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/stdbool.in.h b/lib/stdbool.in.h
index 4193429..bd629ed 100644
--- a/lib/stdbool.in.h
+++ b/lib/stdbool.in.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2003, 2006-2012 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2003, 2006-2013 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2001.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/lib/stddef.in.h b/lib/stddef.in.h
index e17ef24..614c9bc 100644
--- a/lib/stddef.in.h
+++ b/lib/stddef.in.h
@@ -1,6 +1,6 @@
 /* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
 
-   Copyright (C) 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2009-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/stdint.in.h b/lib/stdint.in.h
index 3a73abf..889bca7 100644
--- a/lib/stdint.in.h
+++ b/lib/stdint.in.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2002, 2004-2012 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2002, 2004-2013 Free Software Foundation, Inc.
    Written by Paul Eggert, Bruno Haible, Sam Steingold, Peter Burwood.
    This file is part of gnulib.
 
@@ -39,7 +39,7 @@
    Ideally we should test __BIONIC__ here, but it is only defined after
    <sys/cdefs.h> has been included; hence test __ANDROID__ instead.  */
 #if defined __ANDROID__ \
-    && defined _SYS_TYPES_H_ && !defined _SSIZE_T_DEFINED_
+    && defined _SYS_TYPES_H_ && !defined __need_size_t
 # @INCLUDE_NEXT@ @NEXT_STDINT_H@
 #else
 
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index f7e06ad..bc3fccb 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -1,6 +1,6 @@
 /* A GNU-like <stdio.h>.
 
-   Copyright (C) 2004, 2007-2012 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2007-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -575,21 +575,17 @@ _GL_CXXALIAS_RPL (fwrite, size_t,
 _GL_CXXALIAS_SYS (fwrite, size_t,
                   (const void *ptr, size_t s, size_t n, FILE *stream));
 
-/* Work around glibc bug 11959
+/* Work around bug 11959 when fortifying glibc 2.4 through 2.15
    <http://sources.redhat.com/bugzilla/show_bug.cgi?id=11959>,
    which sometimes causes an unwanted diagnostic for fwrite calls.
-   This affects only function declaration attributes, so it's not
-   needed for C++.  */
-#  if !defined __cplusplus && 0 < __USE_FORTIFY_LEVEL
-static inline size_t _GL_ARG_NONNULL ((1, 4))
-rpl_fwrite (const void *ptr, size_t s, size_t n, FILE *stream)
-{
-  size_t r = fwrite (ptr, s, n, stream);
-  (void) r;
-  return r;
-}
+   This affects only function declaration attributes under certain
+   versions of gcc, and is not needed for C++.  */
+#  if (0 < __USE_FORTIFY_LEVEL                                          \
+       && __GLIBC__ == 2 && 4 <= __GLIBC_MINOR__ && __GLIBC_MINOR__ <= 15 \
+       && 3 < __GNUC__ + (4 <= __GNUC_MINOR__)                          \
+       && !defined __cplusplus)
 #   undef fwrite
-#   define fwrite rpl_fwrite
+#   define fwrite(a, b, c, d) ({size_t __r = fwrite (a, b, c, d); __r; })
 #  endif
 # endif
 _GL_CXXALIASWARN (fwrite);
@@ -1333,7 +1329,6 @@ _GL_WARN_ON_USE (vsprintf, "vsprintf is not always POSIX 
compliant - "
                       "POSIX compliance");
 #endif
 
-
 #endif /* address@hidden@_STDIO_H */
 #endif /* address@hidden@_STDIO_H */
 #endif
diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h
index b67a348..552fdf0 100644
--- a/lib/stdlib.in.h
+++ b/lib/stdlib.in.h
@@ -1,6 +1,6 @@
 /* A GNU-like <stdlib.h>.
 
-   Copyright (C) 1995, 2001-2004, 2006-2012 Free Software Foundation, Inc.
+   Copyright (C) 1995, 2001-2004, 2006-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -20,8 +20,9 @@
 #endif
 @PRAGMA_COLUMNS@
 
-#if defined __need_malloc_and_calloc
-/* Special invocation convention inside glibc header files.  */
+#if defined __need_system_stdlib_h || defined __need_malloc_and_calloc
+/* Special invocation conventions inside some gnulib header files,
+   and inside some glibc header files, respectively.  */
 
 address@hidden@ @NEXT_STDLIB_H@
 
@@ -766,6 +767,22 @@ _GL_WARN_ON_USE (rpmatch, "rpmatch is unportable - "
 # endif
 #endif
 
+#if @GNULIB_SECURE_GETENV@
+/* Look up NAME in the environment, returning 0 in insecure situations.  */
+# if address@hidden@
+_GL_FUNCDECL_SYS (secure_getenv, char *,
+                  (char const *name) _GL_ARG_NONNULL ((1)));
+# endif
+_GL_CXXALIAS_SYS (secure_getenv, char *, (char const *name));
+_GL_CXXALIASWARN (secure_getenv);
+#elif defined GNULIB_POSIXCHECK
+# undef secure_getenv
+# if HAVE_RAW_DECL_SECURE_GETENV
+_GL_WARN_ON_USE (secure_getenv, "secure_getenv is unportable - "
+                 "use gnulib module secure_getenv for portability");
+# endif
+#endif
+
 #if @GNULIB_SETENV@
 /* Set NAME to VALUE in the environment.
    If REPLACE is nonzero, overwrite an existing value.  */
diff --git a/lib/streq.h b/lib/streq.h
index 7fd07c8..03ede61 100644
--- a/lib/streq.h
+++ b/lib/streq.h
@@ -1,5 +1,5 @@
 /* Optimized string comparison.
-   Copyright (C) 2001-2002, 2007, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2001-2002, 2007, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify it
    under the terms of the GNU Lesser General Public License as published
diff --git a/lib/strftime.c b/lib/strftime.c
index f5fc3c9..058ba11 100644
--- a/lib/strftime.c
+++ b/lib/strftime.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2001, 2003-2007, 2009-2012 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2001, 2003-2007, 2009-2013 Free Software Foundation, Inc.
 
    NOTE: The canonical source of this file is maintained with the GNU C 
Library.
    Bugs can be reported to address@hidden
@@ -26,7 +26,6 @@
 #else
 # include <config.h>
 # if FPRINTFTIME
-#  include "ignore-value.h"
 #  include "fprintftime.h"
 # else
 #  include "strftime.h"
@@ -210,13 +209,12 @@ extern char *tzname[];
            fwrite_uppcase (p, (s), _n);                                       \
          else                                                                 \
            {                                                                  \
-             /* We are ignoring the value of fwrite here, in spite of the     \
-                fact that technically, that may not be valid: the fwrite      \
-                specification in POSIX 2008 defers to that of fputc, which    \
-                is intended to be consistent with the one from ISO C,         \
-                which permits failure due to ENOMEM *without* setting the     \
-                stream's error indicator.  */                                 \
-             ignore_value (fwrite ((s), _n, 1, p));                           \
+             /* Ignore the value of fwrite.  The caller can determine whether \
+                an error occurred by inspecting ferror (P).  All known fwrite \
+                implementations set the stream's error indicator when they    \
+                fail due to ENOMEM etc., even though C11 and POSIX.1-2008 do  \
+                not require this.  */                                         \
+             fwrite (s, _n, 1, p);                                            \
            }                                                                  \
        }                                                                      \
      while (0)                                                                \
diff --git a/lib/strftime.h b/lib/strftime.h
index 596b0b8..a521875 100644
--- a/lib/strftime.h
+++ b/lib/strftime.h
@@ -1,6 +1,6 @@
 /* declarations for strftime.c
 
-   Copyright (C) 2002, 2004, 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/striconveh.c b/lib/striconveh.c
index 8a38236..bc841eb 100644
--- a/lib/striconveh.c
+++ b/lib/striconveh.c
@@ -1,5 +1,5 @@
 /* Character set conversion with error handling.
-   Copyright (C) 2001-2012 Free Software Foundation, Inc.
+   Copyright (C) 2001-2013 Free Software Foundation, Inc.
    Written by Bruno Haible and Simon Josefsson.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/striconveh.h b/lib/striconveh.h
index 77730a0..ea6a6dc 100644
--- a/lib/striconveh.h
+++ b/lib/striconveh.h
@@ -1,5 +1,5 @@
 /* Character set conversion with error handling.
-   Copyright (C) 2001-2007, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2001-2007, 2009-2013 Free Software Foundation, Inc.
    Written by Bruno Haible and Simon Josefsson.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/string.in.h b/lib/string.in.h
index 0c23526..5dcf8de 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -1,6 +1,6 @@
 /* A GNU-like <string.h>.
 
-   Copyright (C) 1995-1996, 2001-2012 Free Software Foundation, Inc.
+   Copyright (C) 1995-1996, 2001-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/stripslash.c b/lib/stripslash.c
index 63b77cd..16d4339 100644
--- a/lib/stripslash.c
+++ b/lib/stripslash.c
@@ -1,6 +1,6 @@
 /* stripslash.c -- remove redundant trailing slashes from a file name
 
-   Copyright (C) 1990, 2001, 2003-2006, 2009-2012 Free Software Foundation,
+   Copyright (C) 1990, 2001, 2003-2006, 2009-2013 Free Software Foundation,
    Inc.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/sys_file.in.h b/lib/sys_file.in.h
index 476f2f6..152311c 100644
--- a/lib/sys_file.in.h
+++ b/lib/sys_file.in.h
@@ -1,6 +1,6 @@
 /* Provide a more complete sys/file.h.
 
-   Copyright (C) 2007-2012 Free Software Foundation, Inc.
+   Copyright (C) 2007-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/sys_select.in.h b/lib/sys_select.in.h
new file mode 100644
index 0000000..0e3e32d
--- /dev/null
+++ b/lib/sys_select.in.h
@@ -0,0 +1,309 @@
+/* Substitute for <sys/select.h>.
+   Copyright (C) 2007-2013 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
+
+# if __GNUC__ >= 3
address@hidden@
+# endif
address@hidden@
+
+/* On OSF/1 and Solaris 2.6, <sys/types.h> and <sys/time.h>
+   both include <sys/select.h>.
+   Simply delegate to the system's header in this case.  */
+#if (@HAVE_SYS_SELECT_H@                                                \
+     && ((defined __osf__ && defined _SYS_TYPES_H_ && defined _OSF_SOURCE) \
+         || (defined __sun && defined _SYS_TYPES_H                      \
+             && (! (defined _XOPEN_SOURCE || defined _POSIX_C_SOURCE)   \
+                 || defined __EXTENSIONS__)))                           \
+     && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H)
+
+# define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H
+# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
+
+#elif (@HAVE_SYS_SELECT_H@                                              \
+       && ((defined __osf__ && defined _SYS_TIME_H_ && defined _OSF_SOURCE) \
+           || (defined __sun && defined _SYS_TIME_H                     \
+               && (! (defined _XOPEN_SOURCE || defined _POSIX_C_SOURCE) \
+                   || defined __EXTENSIONS__)))                         \
+       && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H)
+
+# define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H
+# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
+
+/* On IRIX 6.5, <sys/timespec.h> includes <sys/types.h>, which includes
+   <sys/bsd_types.h>, which includes <sys/select.h>.  At this point we cannot
+   include <signal.h>, because that includes <internal/signal_core.h>, which
+   gives a syntax error because <sys/timespec.h> has not been completely
+   processed.  Simply delegate to the system's header in this case.  */
+#elif @HAVE_SYS_SELECT_H@ && defined __sgi && (defined _SYS_BSD_TYPES_H && 
!defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_BSD_TYPES_H)
+
+# define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_BSD_TYPES_H
+# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
+
+/* On OpenBSD 5.0, <pthread.h> includes <sys/types.h>, which includes
+   <sys/select.h>.  At this point we cannot include <signal.h>, because that
+   includes gnulib's pthread.h override, which gives a syntax error because
+   /usr/include/pthread.h has not been completely processed.  Simply delegate
+   to the system's header in this case.  */
+#elif @HAVE_SYS_SELECT_H@ && defined __OpenBSD__ && (defined _PTHREAD_H_ && 
!defined PTHREAD_MUTEX_INITIALIZER)
+
+# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
+
+#else
+
+#ifndef address@hidden@_SYS_SELECT_H
+
+/* On many platforms, <sys/select.h> assumes prior inclusion of
+   <sys/types.h>.  Also, mingw defines sigset_t there, instead of
+   in <signal.h> where it belongs.  */
+#include <sys/types.h>
+
+#if @HAVE_SYS_SELECT_H@
+
+/* On OSF/1 4.0, <sys/select.h> provides only a forward declaration
+   of 'struct timeval', and no definition of this type.
+   Also, Mac OS X, AIX, HP-UX, IRIX, Solaris, Interix declare select()
+   in <sys/time.h>.
+   But avoid namespace pollution on glibc systems.  */
+# ifndef __GLIBC__
+#  include <sys/time.h>
+# endif
+
+/* On AIX 7 and Solaris 10, <sys/select.h> provides an FD_ZERO implementation
+   that relies on memset(), but without including <string.h>.
+   But in any case avoid namespace pollution on glibc systems.  */
+# if (defined __OpenBSD__ || defined _AIX || defined __sun || defined __osf__ 
|| defined __BEOS__) \
+     && ! defined __GLIBC__
+#  include <string.h>
+# endif
+
+/* The include_next requires a split double-inclusion guard.  */
+# @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@
+
+#endif
+
+/* Get definition of 'sigset_t'.
+   But avoid namespace pollution on glibc systems.
+   Do this after the include_next (for the sake of OpenBSD 5.0) but before
+   the split double-inclusion guard (for the sake of Solaris).  */
+#if !(defined __GLIBC__ && !defined __UCLIBC__)
+# include <signal.h>
+#endif
+
+#ifndef address@hidden@_SYS_SELECT_H
+#define address@hidden@_SYS_SELECT_H
+
+#if address@hidden@
+/* A platform that lacks <sys/select.h>.  */
+/* Get the 'struct timeval' and 'fd_set' types and the FD_* macros
+   on most platforms.  */
+# include <sys/time.h>
+/* On HP-UX 11, <sys/time.h> provides an FD_ZERO implementation
+   that relies on memset(), but without including <string.h>.  */
+# if defined __hpux
+#  include <string.h>
+# endif
+/* On native Windows platforms:
+   Get the 'fd_set' type.
+   Get the close() declaration before we override it.  */
+# if @HAVE_WINSOCK2_H@
+#  if !defined _GL_INCLUDING_WINSOCK2_H
+#   define _GL_INCLUDING_WINSOCK2_H
+#   include <winsock2.h>
+#   undef _GL_INCLUDING_WINSOCK2_H
+#  endif
+#  include <io.h>
+# endif
+#endif
+
+/* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
+
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
+
+/* Fix some definitions from <winsock2.h>.  */
+
+#if @HAVE_WINSOCK2_H@
+
+# if !GNULIB_defined_rpl_fd_isset
+
+/* Re-define FD_ISSET to avoid a WSA call while we are not using
+   network sockets.  */
+static int
+rpl_fd_isset (SOCKET fd, fd_set * set)
+{
+  u_int i;
+  if (set == NULL)
+    return 0;
+
+  for (i = 0; i < set->fd_count; i++)
+    if (set->fd_array[i] == fd)
+      return 1;
+
+  return 0;
+}
+
+#  define GNULIB_defined_rpl_fd_isset 1
+# endif
+
+# undef FD_ISSET
+# define FD_ISSET(fd, set) rpl_fd_isset(fd, set)
+
+#endif
+
+/* Hide some function declarations from <winsock2.h>.  */
+
+#if @HAVE_WINSOCK2_H@
+# if !defined address@hidden@_UNISTD_H
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef close
+#   define close close_used_without_including_unistd_h
+#  else
+    _GL_WARN_ON_USE (close,
+                     "close() used without including <unistd.h>");
+#  endif
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef gethostname
+#   define gethostname gethostname_used_without_including_unistd_h
+#  else
+    _GL_WARN_ON_USE (gethostname,
+                     "gethostname() used without including <unistd.h>");
+#  endif
+# endif
+# if !defined address@hidden@_SYS_SOCKET_H
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef socket
+#   define socket              socket_used_without_including_sys_socket_h
+#   undef connect
+#   define connect             connect_used_without_including_sys_socket_h
+#   undef accept
+#   define accept              accept_used_without_including_sys_socket_h
+#   undef bind
+#   define bind                bind_used_without_including_sys_socket_h
+#   undef getpeername
+#   define getpeername         getpeername_used_without_including_sys_socket_h
+#   undef getsockname
+#   define getsockname         getsockname_used_without_including_sys_socket_h
+#   undef getsockopt
+#   define getsockopt          getsockopt_used_without_including_sys_socket_h
+#   undef listen
+#   define listen              listen_used_without_including_sys_socket_h
+#   undef recv
+#   define recv                recv_used_without_including_sys_socket_h
+#   undef send
+#   define send                send_used_without_including_sys_socket_h
+#   undef recvfrom
+#   define recvfrom            recvfrom_used_without_including_sys_socket_h
+#   undef sendto
+#   define sendto              sendto_used_without_including_sys_socket_h
+#   undef setsockopt
+#   define setsockopt          setsockopt_used_without_including_sys_socket_h
+#   undef shutdown
+#   define shutdown            shutdown_used_without_including_sys_socket_h
+#  else
+    _GL_WARN_ON_USE (socket,
+                     "socket() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (connect,
+                     "connect() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (accept,
+                     "accept() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (bind,
+                     "bind() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (getpeername,
+                     "getpeername() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (getsockname,
+                     "getsockname() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (getsockopt,
+                     "getsockopt() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (listen,
+                     "listen() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (recv,
+                     "recv() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (send,
+                     "send() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (recvfrom,
+                     "recvfrom() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (sendto,
+                     "sendto() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (setsockopt,
+                     "setsockopt() used without including <sys/socket.h>");
+    _GL_WARN_ON_USE (shutdown,
+                     "shutdown() used without including <sys/socket.h>");
+#  endif
+# endif
+#endif
+
+
+#if @GNULIB_PSELECT@
+# if @REPLACE_PSELECT@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef pselect
+#   define pselect rpl_pselect
+#  endif
+_GL_FUNCDECL_RPL (pselect, int,
+                  (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
+                   struct timespec const *restrict, const sigset_t *restrict));
+_GL_CXXALIAS_RPL (pselect, int,
+                  (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
+                   struct timespec const *restrict, const sigset_t *restrict));
+# else
+#  if address@hidden@
+_GL_FUNCDECL_SYS (pselect, int,
+                  (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
+                   struct timespec const *restrict, const sigset_t *restrict));
+#  endif
+_GL_CXXALIAS_SYS (pselect, int,
+                  (int, fd_set *restrict, fd_set *restrict, fd_set *restrict,
+                   struct timespec const *restrict, const sigset_t *restrict));
+# endif
+_GL_CXXALIASWARN (pselect);
+#elif defined GNULIB_POSIXCHECK
+# undef pselect
+# if HAVE_RAW_DECL_PSELECT
+_GL_WARN_ON_USE (pselect, "pselect is not portable - "
+                 "use gnulib module pselect for portability");
+# endif
+#endif
+
+#if @GNULIB_SELECT@
+# if @REPLACE_SELECT@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef select
+#   define select rpl_select
+#  endif
+_GL_FUNCDECL_RPL (select, int,
+                  (int, fd_set *, fd_set *, fd_set *, struct timeval *));
+_GL_CXXALIAS_RPL (select, int,
+                  (int, fd_set *, fd_set *, fd_set *, struct timeval *));
+# else
+_GL_CXXALIAS_SYS (select, int,
+                  (int, fd_set *, fd_set *, fd_set *, struct timeval *));
+# endif
+_GL_CXXALIASWARN (select);
+#elif @HAVE_WINSOCK2_H@
+# undef select
+# define select select_used_without_requesting_gnulib_module_select
+#elif defined GNULIB_POSIXCHECK
+# undef select
+# if HAVE_RAW_DECL_SELECT
+_GL_WARN_ON_USE (select, "select is not always POSIX compliant - "
+                 "use gnulib module select for portability");
+# endif
+#endif
+
+
+#endif /* address@hidden@_SYS_SELECT_H */
+#endif /* address@hidden@_SYS_SELECT_H */
+#endif /* OSF/1 */
diff --git a/lib/sys_socket.c b/lib/sys_socket.c
new file mode 100644
index 0000000..3f017f8
--- /dev/null
+++ b/lib/sys_socket.c
@@ -0,0 +1,3 @@
+#include <config.h>
+#define _GL_SYS_SOCKET_INLINE _GL_EXTERN_INLINE
+#include "sys/socket.h"
diff --git a/lib/sys_socket.in.h b/lib/sys_socket.in.h
index a0bcffb..31ed042 100644
--- a/lib/sys_socket.in.h
+++ b/lib/sys_socket.in.h
@@ -1,6 +1,6 @@
 /* Provide a sys/socket header file for systems lacking it (read: MinGW)
    and for systems where it is incomplete.
-   Copyright (C) 2005-2012 Free Software Foundation, Inc.
+   Copyright (C) 2005-2013 Free Software Foundation, Inc.
    Written by Simon Josefsson.
 
    This program is free software; you can redistribute it and/or modify
@@ -63,6 +63,11 @@
 #ifndef address@hidden@_SYS_SOCKET_H
 #define address@hidden@_SYS_SOCKET_H
 
+_GL_INLINE_HEADER_BEGIN
+#ifndef _GL_SYS_SOCKET_INLINE
+# define _GL_SYS_SOCKET_INLINE _GL_INLINE
+#endif
+
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
 /* The definition of _GL_ARG_NONNULL is copied here.  */
@@ -201,7 +206,7 @@ struct msghdr {
 
 /* Re-define FD_ISSET to avoid a WSA call while we are not using
    network sockets.  */
-static inline int
+_GL_SYS_SOCKET_INLINE int
 rpl_fd_isset (SOCKET fd, fd_set * set)
 {
   u_int i;
@@ -677,6 +682,8 @@ _GL_WARN_ON_USE (accept4, "accept4 is unportable - "
 # endif
 #endif
 
+_GL_INLINE_HEADER_END
+
 #endif /* address@hidden@_SYS_SOCKET_H */
 #endif /* address@hidden@_SYS_SOCKET_H */
 #endif
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index 97fb3c4..12f99da 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -1,5 +1,5 @@
 /* Provide a more complete sys/stat header file.
-   Copyright (C) 2005-2012 Free Software Foundation, Inc.
+   Copyright (C) 2005-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -150,6 +150,10 @@
 # endif
 #endif
 
+#ifndef S_ISMPX /* AIX */
+# define S_ISMPX(m) 0
+#endif
+
 #ifndef S_ISNAM /* Xenix */
 # ifdef S_IFNAM
 #  define S_ISNAM(m) (((m) & S_IFMT) == S_IFNAM)
@@ -497,7 +501,7 @@ _GL_CXXALIAS_RPL (mkdir, int, (char const *name, mode_t 
mode));
 # if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
 
 #  if !GNULIB_defined_rpl_mkdir
-static inline int
+static int
 rpl_mkdir (char const *name, mode_t mode)
 {
   return _mkdir (name);
diff --git a/lib/sys_time.in.h b/lib/sys_time.in.h
index 3dbbf91..f2398c5 100644
--- a/lib/sys_time.in.h
+++ b/lib/sys_time.in.h
@@ -1,6 +1,6 @@
 /* Provide a more complete sys/time.h.
 
-   Copyright (C) 2007-2012 Free Software Foundation, Inc.
+   Copyright (C) 2007-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -17,37 +17,34 @@
 
 /* Written by Paul Eggert.  */
 
+#ifndef address@hidden@_SYS_TIME_H
+
 #if __GNUC__ >= 3
 @PRAGMA_SYSTEM_HEADER@
 #endif
 @PRAGMA_COLUMNS@
 
-#if defined address@hidden@_SYS_TIME_H
-
-/* Simply delegate to the system's header, without adding anything.  */
-# if @HAVE_SYS_TIME_H@
-#  @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
-# endif
-
-#else
+/* The include_next requires a split double-inclusion guard.  */
+#if @HAVE_SYS_TIME_H@
+# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
+#endif
 
-# define address@hidden@_SYS_TIME_H
+#ifndef address@hidden@_SYS_TIME_H
+#define address@hidden@_SYS_TIME_H
 
-# if @HAVE_SYS_TIME_H@
-#  @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
-# else
-#  include <time.h>
-# endif
+#if ! @HAVE_SYS_TIME_H@
+# include <time.h>
+#endif
 
 /* On native Windows with MSVC, get the 'struct timeval' type.
    Also, on native Windows with a 64-bit time_t, where we are overriding the
    'struct timeval' type, get all declarations of system functions whose
    signature contains 'struct timeval'.  */
-# if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && 
!defined _GL_INCLUDING_WINSOCK2_H
-#  define _GL_INCLUDING_WINSOCK2_H
-#  include <winsock2.h>
-#  undef _GL_INCLUDING_WINSOCK2_H
-# endif
+#if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && 
!defined _GL_INCLUDING_WINSOCK2_H
+# define _GL_INCLUDING_WINSOCK2_H
+# include <winsock2.h>
+# undef _GL_INCLUDING_WINSOCK2_H
+#endif
 
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
@@ -55,112 +52,112 @@
 
 /* The definition of _GL_WARN_ON_USE is copied here.  */
 
-# ifdef __cplusplus
+#ifdef __cplusplus
 extern "C" {
-# endif
+#endif
 
-# if address@hidden@ || @REPLACE_STRUCT_TIMEVAL@
+#if address@hidden@ || @REPLACE_STRUCT_TIMEVAL@
 
-#  if @REPLACE_STRUCT_TIMEVAL@
-#   define timeval rpl_timeval
-#  endif
+# if @REPLACE_STRUCT_TIMEVAL@
+#  define timeval rpl_timeval
+# endif
 
-#  if !GNULIB_defined_struct_timeval
+# if !GNULIB_defined_struct_timeval
 struct timeval
 {
   time_t tv_sec;
   long int tv_usec;
 };
-#   define GNULIB_defined_struct_timeval 1
-#  endif
-
+#  define GNULIB_defined_struct_timeval 1
 # endif
 
-# ifdef __cplusplus
+#endif
+
+#ifdef __cplusplus
 }
-# endif
+#endif
 
-# if @GNULIB_GETTIMEOFDAY@
-#  if @REPLACE_GETTIMEOFDAY@
-#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#    undef gettimeofday
-#    define gettimeofday rpl_gettimeofday
-#   endif
+#if @GNULIB_GETTIMEOFDAY@
+# if @REPLACE_GETTIMEOFDAY@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef gettimeofday
+#   define gettimeofday rpl_gettimeofday
+#  endif
 _GL_FUNCDECL_RPL (gettimeofday, int,
                   (struct timeval *restrict, void *restrict)
                   _GL_ARG_NONNULL ((1)));
 _GL_CXXALIAS_RPL (gettimeofday, int,
                   (struct timeval *restrict, void *restrict));
-#  else
-#   if address@hidden@
+# else
+#  if address@hidden@
 _GL_FUNCDECL_SYS (gettimeofday, int,
                   (struct timeval *restrict, void *restrict)
                   _GL_ARG_NONNULL ((1)));
-#   endif
+#  endif
 /* Need to cast, because on glibc systems, by default, the second argument is
                                                   struct timezone *.  */
 _GL_CXXALIAS_SYS_CAST (gettimeofday, int,
                        (struct timeval *restrict, void *restrict));
-#  endif
+# endif
 _GL_CXXALIASWARN (gettimeofday);
-# elif defined GNULIB_POSIXCHECK
-#  undef gettimeofday
-#  if HAVE_RAW_DECL_GETTIMEOFDAY
+#elif defined GNULIB_POSIXCHECK
+# undef gettimeofday
+# if HAVE_RAW_DECL_GETTIMEOFDAY
 _GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - "
                  "use gnulib module gettimeofday for portability");
-#  endif
 # endif
+#endif
 
 /* Hide some function declarations from <winsock2.h>.  */
 
-# if defined _MSC_VER && @HAVE_WINSOCK2_H@
-#  if !defined address@hidden@_UNISTD_H
-#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#    undef close
-#    define close close_used_without_including_unistd_h
-#   else
+#if defined _MSC_VER && @HAVE_WINSOCK2_H@
+# if !defined address@hidden@_UNISTD_H
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef close
+#   define close close_used_without_including_unistd_h
+#  else
      _GL_WARN_ON_USE (close,
                       "close() used without including <unistd.h>");
-#   endif
-#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#    undef gethostname
-#    define gethostname gethostname_used_without_including_unistd_h
-#   else
+#  endif
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef gethostname
+#   define gethostname gethostname_used_without_including_unistd_h
+#  else
      _GL_WARN_ON_USE (gethostname,
                       "gethostname() used without including <unistd.h>");
-#   endif
 #  endif
-#  if !defined address@hidden@_SYS_SOCKET_H
-#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#    undef socket
-#    define socket              socket_used_without_including_sys_socket_h
-#    undef connect
-#    define connect             connect_used_without_including_sys_socket_h
-#    undef accept
-#    define accept              accept_used_without_including_sys_socket_h
-#    undef bind
-#    define bind                bind_used_without_including_sys_socket_h
-#    undef getpeername
-#    define getpeername         getpeername_used_without_including_sys_socket_h
-#    undef getsockname
-#    define getsockname         getsockname_used_without_including_sys_socket_h
-#    undef getsockopt
-#    define getsockopt          getsockopt_used_without_including_sys_socket_h
-#    undef listen
-#    define listen              listen_used_without_including_sys_socket_h
-#    undef recv
-#    define recv                recv_used_without_including_sys_socket_h
-#    undef send
-#    define send                send_used_without_including_sys_socket_h
-#    undef recvfrom
-#    define recvfrom            recvfrom_used_without_including_sys_socket_h
-#    undef sendto
-#    define sendto              sendto_used_without_including_sys_socket_h
-#    undef setsockopt
-#    define setsockopt          setsockopt_used_without_including_sys_socket_h
-#    undef shutdown
-#    define shutdown            shutdown_used_without_including_sys_socket_h
-#   else
+# endif
+# if !defined address@hidden@_SYS_SOCKET_H
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef socket
+#   define socket              socket_used_without_including_sys_socket_h
+#   undef connect
+#   define connect             connect_used_without_including_sys_socket_h
+#   undef accept
+#   define accept              accept_used_without_including_sys_socket_h
+#   undef bind
+#   define bind                bind_used_without_including_sys_socket_h
+#   undef getpeername
+#   define getpeername         getpeername_used_without_including_sys_socket_h
+#   undef getsockname
+#   define getsockname         getsockname_used_without_including_sys_socket_h
+#   undef getsockopt
+#   define getsockopt          getsockopt_used_without_including_sys_socket_h
+#   undef listen
+#   define listen              listen_used_without_including_sys_socket_h
+#   undef recv
+#   define recv                recv_used_without_including_sys_socket_h
+#   undef send
+#   define send                send_used_without_including_sys_socket_h
+#   undef recvfrom
+#   define recvfrom            recvfrom_used_without_including_sys_socket_h
+#   undef sendto
+#   define sendto              sendto_used_without_including_sys_socket_h
+#   undef setsockopt
+#   define setsockopt          setsockopt_used_without_including_sys_socket_h
+#   undef shutdown
+#   define shutdown            shutdown_used_without_including_sys_socket_h
+#  else
      _GL_WARN_ON_USE (socket,
                       "socket() used without including <sys/socket.h>");
      _GL_WARN_ON_USE (connect,
@@ -189,17 +186,18 @@ _GL_WARN_ON_USE (gettimeofday, "gettimeofday is 
unportable - "
                       "setsockopt() used without including <sys/socket.h>");
      _GL_WARN_ON_USE (shutdown,
                       "shutdown() used without including <sys/socket.h>");
-#   endif
 #  endif
-#  if !defined address@hidden@_SYS_SELECT_H
-#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#    undef select
-#    define select select_used_without_including_sys_select_h
-#   else
+# endif
+# if !defined address@hidden@_SYS_SELECT_H
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   undef select
+#   define select select_used_without_including_sys_select_h
+#  else
      _GL_WARN_ON_USE (select,
                       "select() used without including <sys/select.h>");
-#   endif
 #  endif
 # endif
+#endif
 
 #endif /* address@hidden@_SYS_TIME_H */
+#endif /* address@hidden@_SYS_TIME_H */
diff --git a/lib/sys_times.in.h b/lib/sys_times.in.h
new file mode 100644
index 0000000..8ea8088
--- /dev/null
+++ b/lib/sys_times.in.h
@@ -0,0 +1,80 @@
+/* Provide a sys/times.h header file.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Simon Josefsson <address@hidden>, 2008.  */
+
+/* This file is supposed to be used on platforms where <sys/times.h>
+   is missing.  */
+
+#ifndef address@hidden@_SYS_TIMES_H
+
+# if __GNUC__ >= 3
address@hidden@
+# endif
address@hidden@
+
+# if @HAVE_SYS_TIMES_H@
+#  @INCLUDE_NEXT@ @NEXT_SYS_TIMES_H@
+# endif
+
+# define address@hidden@_SYS_TIMES_H
+
+/* Get clock_t.
+   But avoid namespace pollution on glibc systems.  */
+# ifndef __GLIBC__
+#  include <time.h>
+# endif
+
+/* The definition of _GL_ARG_NONNULL is copied here.  */
+
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+# if address@hidden@
+#  if !GNULIB_defined_struct_tms
+  /* Structure describing CPU time used by a process and its children.  */
+  struct tms
+  {
+    clock_t tms_utime;          /* User CPU time.  */
+    clock_t tms_stime;          /* System CPU time.  */
+
+    clock_t tms_cutime;         /* User CPU time of dead children.  */
+    clock_t tms_cstime;         /* System CPU time of dead children.  */
+  };
+#   define GNULIB_defined_struct_tms 1
+#  endif
+# endif
+
+# if @GNULIB_TIMES@
+#  if address@hidden@
+  extern clock_t times (struct tms *buffer) _GL_ARG_NONNULL ((1));
+#  endif
+# elif defined GNULIB_POSIXCHECK
+#  undef times
+#  if HAVE_RAW_DECL_TIMES
+_GL_WARN_ON_USE (times, "times is unportable - "
+                 "use gnulib module times for portability");
+#  endif
+# endif
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif                          /* address@hidden@_SYS_TIMES_H */
diff --git a/lib/sys_types.in.h b/lib/sys_types.in.h
index 6eedaeb..520f6c8 100644
--- a/lib/sys_types.in.h
+++ b/lib/sys_types.in.h
@@ -1,6 +1,6 @@
 /* Provide a more complete sys/types.h.
 
-   Copyright (C) 2011-2012 Free Software Foundation, Inc.
+   Copyright (C) 2011-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/sys_uio.in.h b/lib/sys_uio.in.h
index 73c34be..6f605df 100644
--- a/lib/sys_uio.in.h
+++ b/lib/sys_uio.in.h
@@ -1,5 +1,5 @@
 /* Substitute for <sys/uio.h>.
-   Copyright (C) 2011-2012 Free Software Foundation, Inc.
+   Copyright (C) 2011-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/time.in.h b/lib/time.in.h
index 11c6ca1..71dcc36 100644
--- a/lib/time.in.h
+++ b/lib/time.in.h
@@ -1,6 +1,6 @@
 /* A more-standard <time.h>.
 
-   Copyright (C) 2007-2012 Free Software Foundation, Inc.
+   Copyright (C) 2007-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/time_r.c b/lib/time_r.c
index 267c18d..9a61794 100644
--- a/lib/time_r.c
+++ b/lib/time_r.c
@@ -1,6 +1,6 @@
 /* Reentrant time functions like localtime_r.
 
-   Copyright (C) 2003, 2006-2007, 2010-2012 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2006-2007, 2010-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/times.c b/lib/times.c
new file mode 100644
index 0000000..cf2fa1d
--- /dev/null
+++ b/lib/times.c
@@ -0,0 +1,66 @@
+/* Get process times
+
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
+
+/* Written by Simon Josefsson <address@hidden>, 2008.  */
+
+#include <config.h>
+
+/* Get times prototype. */
+#include <sys/times.h>
+
+/* Get round. */
+#include <math.h>
+
+/* Get GetProcessTimes etc. */
+#include <windows.h>
+
+static clock_t
+filetime2clock (FILETIME time)
+{
+  float f;
+
+  /* We have a 64-bit value, in the form of two DWORDS aka unsigned
+     int, counting the number of 100-nanosecond intervals.  We need to
+     convert these to clock ticks.  Older POSIX uses CLK_TCK to
+     indicate the number of clock ticks per second while modern POSIX
+     uses sysconf(_SC_CLK_TCK).  Mingw32 does not appear to have
+     sysconf(_SC_CLK_TCK), but appears to have CLK_TCK = 1000 so we
+     use it.  Note that CLOCKS_PER_SEC constant does not apply here,
+     it is for use with the clock function.  */
+
+  f = (unsigned long long) time.dwHighDateTime << 32;
+  f += time.dwLowDateTime;
+  f = f * CLK_TCK / 10000000;
+  return (clock_t) round (f);
+}
+
+clock_t
+times (struct tms * buffer)
+{
+  FILETIME creation_time, exit_time, kernel_time, user_time;
+
+  if (GetProcessTimes (GetCurrentProcess (), &creation_time, &exit_time,
+                       &kernel_time, &user_time) == 0)
+    return (clock_t) -1;
+
+  buffer->tms_utime = filetime2clock (user_time);
+  buffer->tms_stime = filetime2clock (kernel_time);
+  buffer->tms_cutime = 0;
+  buffer->tms_cstime = 0;
+
+  return filetime2clock (creation_time);
+}
diff --git a/lib/trunc.c b/lib/trunc.c
index 3b86ef0..26a784b 100644
--- a/lib/trunc.c
+++ b/lib/trunc.c
@@ -1,5 +1,5 @@
 /* Round towards zero.
-   Copyright (C) 2007, 2010-2012 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2010-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/unistd.c b/lib/unistd.c
new file mode 100644
index 0000000..6c6a8e2
--- /dev/null
+++ b/lib/unistd.c
@@ -0,0 +1,3 @@
+#include <config.h>
+#define _GL_UNISTD_INLINE _GL_EXTERN_INLINE
+#include "unistd.h"
diff --git a/lib/unistd.in.h b/lib/unistd.in.h
index e96a39c..84bed4a 100644
--- a/lib/unistd.in.h
+++ b/lib/unistd.in.h
@@ -1,5 +1,5 @@
 /* Substitute for and wrapper around <unistd.h>.
-   Copyright (C) 2003-2012 Free Software Foundation, Inc.
+   Copyright (C) 2003-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -14,29 +14,13 @@
    You should have received a copy of the GNU Lesser General Public License
    along with this program; if not, see <http://www.gnu.org/licenses/>.  */
 
+#ifndef address@hidden@_UNISTD_H
+
 #if __GNUC__ >= 3
 @PRAGMA_SYSTEM_HEADER@
 #endif
 @PRAGMA_COLUMNS@
 
-/* Special invocation convention:
-   - On mingw, several headers, including <winsock2.h>, include <unistd.h>,
-     but we need to ensure that both the system <unistd.h> and <winsock2.h>
-     are completely included before we replace gethostname.  */
-#if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ \
-  && !defined _GL_WINSOCK2_H_WITNESS && defined _WINSOCK2_H
-/* <unistd.h> is being indirectly included for the first time from
-   <winsock2.h>; avoid declaring any overrides.  */
-# if @HAVE_UNISTD_H@
-#  @INCLUDE_NEXT@ @NEXT_UNISTD_H@
-# else
-#  error unexpected; report this to address@hidden
-# endif
-# define _GL_WINSOCK2_H_WITNESS
-
-/* Normal invocation.  */
-#elif !defined address@hidden@_UNISTD_H
-
 /* The include_next requires a split double-inclusion guard.  */
 #if @HAVE_UNISTD_H@
 # @INCLUDE_NEXT@ @NEXT_UNISTD_H@
@@ -79,7 +63,9 @@
 /* Solaris declares getcwd not only in <unistd.h> but also in <stdlib.h>.  */
 /* But avoid namespace pollution on glibc systems.  */
 #ifndef __GLIBC__
+# define __need_system_stdlib_h
 # include <stdlib.h>
+# undef __need_system_stdlib_h
 #endif
 
 /* Native Windows platforms declare chdir, getcwd, rmdir in
@@ -124,9 +110,15 @@
 /* Get getopt(), optarg, optind, opterr, optopt.
    But avoid namespace pollution on glibc systems.  */
 #if @GNULIB_UNISTD_H_GETOPT@ && !defined __GLIBC__ && !defined 
_GL_SYSTEM_GETOPT
+# define __need_getopt
 # include <getopt.h>
 #endif
 
+_GL_INLINE_HEADER_BEGIN
+#ifndef _GL_UNISTD_INLINE
+# define _GL_UNISTD_INLINE _GL_INLINE
+#endif
+
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
 /* The definition of _GL_ARG_NONNULL is copied here.  */
@@ -404,7 +396,7 @@ extern char **environ;
 # endif
 #elif defined GNULIB_POSIXCHECK
 # if HAVE_RAW_DECL_ENVIRON
-static inline char ***
+_GL_UNISTD_INLINE char ***
 rpl_environ (void)
 {
   return &environ;
@@ -862,7 +854,7 @@ _GL_CXXALIAS_RPL (getpagesize, int, (void));
 #     define getpagesize() _gl_getpagesize ()
 #    else
 #     if !GNULIB_defined_getpagesize_function
-static inline int
+_GL_UNISTD_INLINE int
 getpagesize ()
 {
   return _gl_getpagesize ();
@@ -1530,6 +1522,7 @@ _GL_CXXALIAS_SYS_CAST (write, ssize_t, (int fd, const 
void *buf, size_t count));
 _GL_CXXALIASWARN (write);
 #endif
 
+_GL_INLINE_HEADER_END
 
 #endif /* address@hidden@_UNISTD_H */
 #endif /* address@hidden@_UNISTD_H */
diff --git a/lib/unistr.in.h b/lib/unistr.in.h
index 2706789..2d28b1f 100644
--- a/lib/unistr.in.h
+++ b/lib/unistr.in.h
@@ -1,5 +1,5 @@
 /* Elementary Unicode string functions.
-   Copyright (C) 2001-2002, 2005-2012 Free Software Foundation, Inc.
+   Copyright (C) 2001-2002, 2005-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify it
    under the terms of the GNU Lesser General Public License as published
diff --git a/lib/unistr/u8-mbtouc-aux.c b/lib/unistr/u8-mbtouc-aux.c
index e68a8e2..0179498 100644
--- a/lib/unistr/u8-mbtouc-aux.c
+++ b/lib/unistr/u8-mbtouc-aux.c
@@ -1,5 +1,5 @@
 /* Conversion UTF-8 to UCS-4.
-   Copyright (C) 2001-2002, 2006-2007, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2001-2002, 2006-2007, 2009-2013 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2001.
 
    This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-mbtouc-unsafe-aux.c 
b/lib/unistr/u8-mbtouc-unsafe-aux.c
index 38db03d..65f792c 100644
--- a/lib/unistr/u8-mbtouc-unsafe-aux.c
+++ b/lib/unistr/u8-mbtouc-unsafe-aux.c
@@ -1,5 +1,5 @@
 /* Conversion UTF-8 to UCS-4.
-   Copyright (C) 2001-2002, 2006-2007, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2001-2002, 2006-2007, 2009-2013 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2001.
 
    This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-mbtouc-unsafe.c b/lib/unistr/u8-mbtouc-unsafe.c
index 6fbde71..8aecdd4 100644
--- a/lib/unistr/u8-mbtouc-unsafe.c
+++ b/lib/unistr/u8-mbtouc-unsafe.c
@@ -1,5 +1,5 @@
 /* Look at first character in UTF-8 string.
-   Copyright (C) 1999-2002, 2006-2007, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 1999-2002, 2006-2007, 2009-2013 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2001.
 
    This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-mbtouc.c b/lib/unistr/u8-mbtouc.c
index d286c27..2e644bb 100644
--- a/lib/unistr/u8-mbtouc.c
+++ b/lib/unistr/u8-mbtouc.c
@@ -1,5 +1,5 @@
 /* Look at first character in UTF-8 string.
-   Copyright (C) 1999-2002, 2006-2007, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 1999-2002, 2006-2007, 2009-2013 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2001.
 
    This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-mbtoucr.c b/lib/unistr/u8-mbtoucr.c
index f01cfe9..7b9d8a7 100644
--- a/lib/unistr/u8-mbtoucr.c
+++ b/lib/unistr/u8-mbtoucr.c
@@ -1,5 +1,5 @@
 /* Look at first character in UTF-8 string, returning an error code.
-   Copyright (C) 1999-2002, 2006-2007, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 1999-2002, 2006-2007, 2009-2013 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2001.
 
    This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-prev.c b/lib/unistr/u8-prev.c
index 04def87..5e97909 100644
--- a/lib/unistr/u8-prev.c
+++ b/lib/unistr/u8-prev.c
@@ -1,5 +1,5 @@
 /* Iterate over previous character in UTF-8 string.
-   Copyright (C) 2002, 2006-2007, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2006-2007, 2009-2013 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2002.
 
    This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-uctomb-aux.c b/lib/unistr/u8-uctomb-aux.c
index 1a44ddb..a6d21a4 100644
--- a/lib/unistr/u8-uctomb-aux.c
+++ b/lib/unistr/u8-uctomb-aux.c
@@ -1,5 +1,5 @@
 /* Conversion UCS-4 to UTF-8.
-   Copyright (C) 2002, 2006-2007, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2006-2007, 2009-2013 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2002.
 
    This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unistr/u8-uctomb.c b/lib/unistr/u8-uctomb.c
index 4bfe261..5e6a825 100644
--- a/lib/unistr/u8-uctomb.c
+++ b/lib/unistr/u8-uctomb.c
@@ -1,5 +1,5 @@
 /* Store a character in UTF-8 string.
-   Copyright (C) 2002, 2005-2006, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2005-2006, 2009-2013 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2002.
 
    This program is free software: you can redistribute it and/or modify it
diff --git a/lib/unitypes.in.h b/lib/unitypes.in.h
index c588589..50a59f1 100644
--- a/lib/unitypes.in.h
+++ b/lib/unitypes.in.h
@@ -1,5 +1,5 @@
 /* Elementary types and macros for the GNU UniString library.
-   Copyright (C) 2002, 2005-2006, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2005-2006, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify it
    under the terms of the GNU Lesser General Public License as published
diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
index 1da25f5..2e6bc80 100644
--- a/lib/vasnprintf.c
+++ b/lib/vasnprintf.c
@@ -1,5 +1,5 @@
 /* vsprintf with automatic memory allocation.
-   Copyright (C) 1999, 2002-2012 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2002-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -1530,7 +1530,7 @@ is_borderline (const char *digits, size_t precision)
 
 /* Returns the number of TCHAR_T units needed as temporary space for the result
    of sprintf or SNPRINTF of a single conversion directive.  */
-static inline size_t
+static size_t
 MAX_ROOM_NEEDED (const arguments *ap, size_t arg_index, FCHAR_T conversion,
                  arg_type type, int flags, size_t width, int has_precision,
                  size_t precision, int pad_ourselves)
diff --git a/lib/vasnprintf.h b/lib/vasnprintf.h
index 277f270..8571eb7 100644
--- a/lib/vasnprintf.h
+++ b/lib/vasnprintf.h
@@ -1,5 +1,5 @@
 /* vsprintf with automatic memory allocation.
-   Copyright (C) 2002-2004, 2007-2012 Free Software Foundation, Inc.
+   Copyright (C) 2002-2004, 2007-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/verify.h b/lib/verify.h
index 780b55e..40b8ef5 100644
--- a/lib/verify.h
+++ b/lib/verify.h
@@ -1,6 +1,6 @@
 /* Compile-time assert-like macros.
 
-   Copyright (C) 2005-2006, 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2005-2006, 2009-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/vsnprintf.c b/lib/vsnprintf.c
index 1d8db4e..4dd428c 100644
--- a/lib/vsnprintf.c
+++ b/lib/vsnprintf.c
@@ -1,5 +1,5 @@
 /* Formatted output to strings.
-   Copyright (C) 2004, 2006-2012 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2006-2013 Free Software Foundation, Inc.
    Written by Simon Josefsson and Yoann Vandoorselaere <address@hidden>.
 
    This program is free software; you can redistribute it and/or modify
diff --git a/lib/w32sock.h b/lib/w32sock.h
index b397115..76c6f9f 100644
--- a/lib/w32sock.h
+++ b/lib/w32sock.h
@@ -1,6 +1,6 @@
 /* w32sock.h --- internal auxiliary functions for Windows socket functions
 
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/wchar.in.h b/lib/wchar.in.h
index 5c93616..97f7dc8 100644
--- a/lib/wchar.in.h
+++ b/lib/wchar.in.h
@@ -1,6 +1,6 @@
 /* A substitute for ISO C99 <wchar.h>, for platforms that have issues.
 
-   Copyright (C) 2007-2012 Free Software Foundation, Inc.
+   Copyright (C) 2007-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/lib/wcrtomb.c b/lib/wcrtomb.c
index a4d6bcd..0aab985 100644
--- a/lib/wcrtomb.c
+++ b/lib/wcrtomb.c
@@ -1,5 +1,5 @@
 /* Convert wide character to multibyte character.
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2008.
 
    This program is free software: you can redistribute it and/or modify
diff --git a/lib/wctype-h.c b/lib/wctype-h.c
new file mode 100644
index 0000000..bb5f847
--- /dev/null
+++ b/lib/wctype-h.c
@@ -0,0 +1,4 @@
+/* Normally this would be wctype.c, but that name's already taken.  */
+#include <config.h>
+#define _GL_WCTYPE_INLINE _GL_EXTERN_INLINE
+#include "wctype.h"
diff --git a/lib/wctype.in.h b/lib/wctype.in.h
index e819d44..246ce9d 100644
--- a/lib/wctype.in.h
+++ b/lib/wctype.in.h
@@ -1,6 +1,6 @@
 /* A substitute for ISO C99 <wctype.h>, for platforms that lack it.
 
-   Copyright (C) 2006-2012 Free Software Foundation, Inc.
+   Copyright (C) 2006-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -54,6 +54,11 @@
 #ifndef address@hidden@_WCTYPE_H
 #define address@hidden@_WCTYPE_H
 
+_GL_INLINE_HEADER_BEGIN
+#ifndef _GL_WCTYPE_INLINE
+# define _GL_WCTYPE_INLINE _GL_INLINE
+#endif
+
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
 
 /* The definition of _GL_WARN_ON_USE is copied here.  */
@@ -148,7 +153,7 @@ typedef unsigned int rpl_wint_t;
 #   endif
 #  endif
 
-static inline int
+_GL_WCTYPE_INLINE int
 #  if @REPLACE_ISWCNTRL@
 rpl_iswalnum
 #  else
@@ -160,7 +165,7 @@ iswalnum
           || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'));
 }
 
-static inline int
+_GL_WCTYPE_INLINE int
 #  if @REPLACE_ISWCNTRL@
 rpl_iswalpha
 #  else
@@ -171,7 +176,7 @@ iswalpha
   return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z';
 }
 
-static inline int
+_GL_WCTYPE_INLINE int
 #  if @REPLACE_ISWCNTRL@
 rpl_iswblank
 #  else
@@ -182,7 +187,7 @@ iswblank
   return wc == ' ' || wc == '\t';
 }
 
-static inline int
+_GL_WCTYPE_INLINE int
 #  if @REPLACE_ISWCNTRL@
 rpl_iswcntrl
 #  else
@@ -193,7 +198,7 @@ iswcntrl
   return (wc & ~0x1f) == 0 || wc == 0x7f;
 }
 
-static inline int
+_GL_WCTYPE_INLINE int
 #  if @REPLACE_ISWCNTRL@
 rpl_iswdigit
 #  else
@@ -204,7 +209,7 @@ iswdigit
   return wc >= '0' && wc <= '9';
 }
 
-static inline int
+_GL_WCTYPE_INLINE int
 #  if @REPLACE_ISWCNTRL@
 rpl_iswgraph
 #  else
@@ -215,7 +220,7 @@ iswgraph
   return wc >= '!' && wc <= '~';
 }
 
-static inline int
+_GL_WCTYPE_INLINE int
 #  if @REPLACE_ISWCNTRL@
 rpl_iswlower
 #  else
@@ -226,7 +231,7 @@ iswlower
   return wc >= 'a' && wc <= 'z';
 }
 
-static inline int
+_GL_WCTYPE_INLINE int
 #  if @REPLACE_ISWCNTRL@
 rpl_iswprint
 #  else
@@ -237,7 +242,7 @@ iswprint
   return wc >= ' ' && wc <= '~';
 }
 
-static inline int
+_GL_WCTYPE_INLINE int
 #  if @REPLACE_ISWCNTRL@
 rpl_iswpunct
 #  else
@@ -250,7 +255,7 @@ iswpunct
                || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')));
 }
 
-static inline int
+_GL_WCTYPE_INLINE int
 #  if @REPLACE_ISWCNTRL@
 rpl_iswspace
 #  else
@@ -262,7 +267,7 @@ iswspace
           || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r');
 }
 
-static inline int
+_GL_WCTYPE_INLINE int
 #  if @REPLACE_ISWCNTRL@
 rpl_iswupper
 #  else
@@ -273,7 +278,7 @@ iswupper
   return wc >= 'A' && wc <= 'Z';
 }
 
-static inline int
+_GL_WCTYPE_INLINE int
 #  if @REPLACE_ISWCNTRL@
 rpl_iswxdigit
 #  else
@@ -285,7 +290,7 @@ iswxdigit
           || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'));
 }
 
-static inline wint_t
+_GL_WCTYPE_INLINE wint_t
 #  if @REPLACE_TOWLOWER@
 rpl_towlower
 #  else
@@ -296,7 +301,7 @@ towlower
   return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc);
 }
 
-static inline wint_t
+_GL_WCTYPE_INLINE wint_t
 #  if @REPLACE_TOWLOWER@
 rpl_towupper
 #  else
@@ -336,7 +341,7 @@ _GL_FUNCDECL_SYS (iswblank, int, (wint_t wc));
       result register.  We need to fix this by adding a zero-extend from
       wchar_t to wint_t after the call.  */
 
-static inline wint_t
+_GL_WCTYPE_INLINE wint_t
 rpl_towlower (wint_t wc)
 {
   return (wint_t) (wchar_t) towlower (wc);
@@ -345,7 +350,7 @@ rpl_towlower (wint_t wc)
 #   define towlower rpl_towlower
 #  endif
 
-static inline wint_t
+_GL_WCTYPE_INLINE wint_t
 rpl_towupper (wint_t wc)
 {
   return (wint_t) (wchar_t) towupper (wc);
@@ -493,6 +498,7 @@ _GL_WARN_ON_USE (towctrans, "towctrans is unportable - "
 # endif
 #endif
 
+_GL_INLINE_HEADER_END
 
 #endif /* address@hidden@_WCTYPE_H */
 #endif /* address@hidden@_WCTYPE_H */
diff --git a/lib/write.c b/lib/write.c
index 2473cdb..d7d00de 100644
--- a/lib/write.c
+++ b/lib/write.c
@@ -1,5 +1,5 @@
 /* POSIX compatible write() function.
-   Copyright (C) 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2008-2013 Free Software Foundation, Inc.
    Written by Bruno Haible <address@hidden>, 2008.
 
    This program is free software: you can redistribute it and/or modify
@@ -40,7 +40,7 @@
 # undef write
 
 # if HAVE_MSVC_INVALID_PARAMETER_HANDLER
-static inline ssize_t
+static ssize_t
 write_nothrow (int fd, const void *buf, size_t count)
 {
   ssize_t result;
diff --git a/lib/xsize.h b/lib/xsize.h
index 8312243..a7a34c5 100644
--- a/lib/xsize.h
+++ b/lib/xsize.h
@@ -1,6 +1,6 @@
 /* xsize.h -- Checked size_t computations.
 
-   Copyright (C) 2003, 2008-2012 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2008-2013 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
diff --git a/libguile/Makefile.am b/libguile/Makefile.am
index d4fb70f..ce437e4 100644
--- a/libguile/Makefile.am
+++ b/libguile/Makefile.am
@@ -1,6 +1,7 @@
 ## Process this file with Automake to create Makefile.in
 ##
-##     Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006, 2007, 
2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
+##   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006, 2007,
+##     2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
 ##
 ##   This file is part of GUILE.
 ##
@@ -93,7 +94,7 @@ guile_filter_doc_snarfage_SOURCES = c-tokenize.c
 c-tokenize.$(OBJEXT): c-tokenize.c
        $(AM_V_GEN) \
        if [ "$(cross_compiling)" = "yes" ]; then \
-               $(CC_FOR_BUILD) -c -o $@ $<; \
+               $(CC_FOR_BUILD) -I$(top_builddir) -c -o $@ $<; \
        else \
                $(COMPILE) -c -o $@ $<; \
        fi
@@ -445,12 +446,16 @@ BUILT_SOURCES = cpp-E.c cpp-SIG.c libpath.h \
     scmconfig.h \
     $(DOT_I_FILES) vm-operations.h $(DOT_X_FILES) $(EXTRA_DOT_X_FILES)
 
+# Force the generation of `guile-procedures.texi' because the top-level
+# Makefile expects it to be built.
+all-local: guile-procedures.texi
+
 address@hidden@_la_SOURCES = _scm.h            \
     memmove.c strerror.c                       \
     dynl.c regex-posix.c                       \
     posix.c net_db.c socket.c                  \
     debug-malloc.c mkstemp.c                   \
-    win32-uname.c win32-socket.c               \
+    win32-uname.c                              \
     locale-categories.h
 
 ## delete guile-snarf.awk from the installation bindir, in case it's
@@ -467,8 +472,8 @@ noinst_HEADERS = conv-integer.i.c conv-uinteger.i.c         
\
                  elf.h                                         \
                  srfi-14.i.c                                   \
                  quicksort.i.c                                  \
-                 win32-uname.h win32-socket.h                  \
-                private-gc.h private-options.h
+                 win32-uname.h                                 \
+                private-gc.h private-options.h ports-internal.h
 
 # vm instructions
 noinst_HEADERS += vm-engine.c vm-i-system.c vm-i-scheme.c vm-i-loader.c
@@ -731,25 +736,9 @@ guile.texi: $(alldotdocfiles) guile$(EXEEXT)
 guile-procedures.texi: $(alldotdocfiles) guile$(EXEEXT)
        $(AM_V_GEN)$(dotdoc2texi)          > $@ || { rm $@; false; }
 
-if HAVE_MAKEINFO
-
-guile-procedures.txt: guile-procedures.texi
-       rm -f $@
-       makeinfo --force -o $@ guile-procedures.texi || test -f $@
-
-else
-
-guile-procedures.txt: guile-procedures.texi
-       cp guile-procedures.texi $@
-
-endif
-
 c-tokenize.c: c-tokenize.lex
        flex -t $(srcdir)/c-tokenize.lex > $@ || { rm $@; false; }
 
-schemelibdir = $(pkgdatadir)/$(GUILE_EFFECTIVE_VERSION)
-schemelib_DATA = guile-procedures.txt
-
 ## Add -MG to make the .x magic work with auto-dep code.
 MKDEP = gcc -M -MG $(DEFS) $(AM_CPPFLAGS) $(CPPFLAGS) $(CFLAGS)
 
diff --git a/libguile/__scm.h b/libguile/__scm.h
index b42b823..0a749be 100644
--- a/libguile/__scm.h
+++ b/libguile/__scm.h
@@ -371,7 +371,7 @@
 #ifdef LONG_BIT
 # define SCM_LONG_BIT LONG_BIT
 #else
-# define SCM_LONG_BIT (SCM_CHAR_BIT * sizeof (long) / sizeof (char))
+# define SCM_LONG_BIT (SCM_SIZEOF_LONG * 8)
 #endif
 
 #define SCM_I_UTYPE_MAX(type)      ((type)-1)
diff --git a/libguile/array-handle.c b/libguile/array-handle.c
index 7114f78..62d8520 100644
--- a/libguile/array-handle.c
+++ b/libguile/array-handle.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1995,1996,1997,1998,2000,2001,2002,2003,2004, 2005, 2006, 
2009, 2011 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,2000,2001,2002,2003,2004, 2005,
+ * 2006, 2009, 2011, 2013 Free Software Foundation, Inc.
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -97,6 +98,47 @@ scm_array_handle_pos (scm_t_array_handle *h, SCM indices)
   return pos;
 }
 
+static void
+check_array_index_bounds (scm_t_array_dim *dim, ssize_t idx)
+{
+  if (idx < dim->lbnd || idx > dim->ubnd)
+    scm_error (scm_out_of_range_key, NULL, "Value out of range ~S to ~S: ~S",
+               scm_list_3 (scm_from_ssize_t (dim->lbnd),
+                           scm_from_ssize_t (dim->ubnd),
+                           scm_from_ssize_t (idx)),
+               scm_list_1 (scm_from_ssize_t (idx)));
+}
+
+ssize_t
+scm_array_handle_pos_1 (scm_t_array_handle *h, ssize_t idx0)
+{
+  scm_t_array_dim *dim = scm_array_handle_dims (h);
+
+  if (scm_array_handle_rank (h) != 1)
+    scm_misc_error (NULL, "wrong number of indices, expecting ~A",
+                   scm_list_1 (scm_from_size_t (scm_array_handle_rank (h))));
+
+  check_array_index_bounds (&dim[0], idx0);
+
+  return (idx0 - dim[0].lbnd) * dim[0].inc;
+}
+
+ssize_t
+scm_array_handle_pos_2 (scm_t_array_handle *h, ssize_t idx0, ssize_t idx1)
+{
+  scm_t_array_dim *dim = scm_array_handle_dims (h);
+
+  if (scm_array_handle_rank (h) != 2)
+    scm_misc_error (NULL, "wrong number of indices, expecting ~A",
+                   scm_list_1 (scm_from_size_t (scm_array_handle_rank (h))));
+
+  check_array_index_bounds (&dim[0], idx0);
+  check_array_index_bounds (&dim[1], idx1);
+
+  return ((idx0 - dim[0].lbnd) * dim[0].inc
+          + (idx1 - dim[1].lbnd) * dim[1].inc);
+}
+
 SCM
 scm_array_handle_element_type (scm_t_array_handle *h)
 {
diff --git a/libguile/array-handle.h b/libguile/array-handle.h
index 2e8af77..fa2449d 100644
--- a/libguile/array-handle.h
+++ b/libguile/array-handle.h
@@ -4,7 +4,7 @@
 #define SCM_ARRAY_HANDLE_H
 
 /* Copyright (C) 1995, 1996, 1997, 1999, 2000, 2001, 2004, 2006,
- *   2008, 2009, 2011 Free Software Foundation, Inc.
+ *   2008, 2009, 2011, 2013 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -25,6 +25,8 @@
 
 
 #include "libguile/__scm.h"
+#include "libguile/error.h"
+#include "libguile/numbers.h"
 
 
 
@@ -112,12 +114,42 @@ typedef struct scm_t_array_handle {
 
 SCM_API void scm_array_get_handle (SCM array, scm_t_array_handle *h);
 SCM_API ssize_t scm_array_handle_pos (scm_t_array_handle *h, SCM indices);
+SCM_API ssize_t scm_array_handle_pos_1 (scm_t_array_handle *h, ssize_t idx0);
+SCM_API ssize_t scm_array_handle_pos_2 (scm_t_array_handle *h, ssize_t idx0, 
ssize_t idx1);
 SCM_API SCM scm_array_handle_element_type (scm_t_array_handle *h);
 SCM_API void scm_array_handle_release (scm_t_array_handle *h);
 SCM_API const SCM* scm_array_handle_elements (scm_t_array_handle *h);
 SCM_API SCM* scm_array_handle_writable_elements (scm_t_array_handle *h);
 
-/* See inline.h for scm_array_handle_ref and scm_array_handle_set */
+
+SCM_INLINE SCM scm_array_handle_ref (scm_t_array_handle *h, ssize_t pos);
+SCM_INLINE void scm_array_handle_set (scm_t_array_handle *h, ssize_t pos, SCM 
val);
+
+#if SCM_CAN_INLINE || defined SCM_INLINE_C_IMPLEMENTING_INLINES
+/* Either inlining, or being included from inline.c.  */
+
+SCM_INLINE_IMPLEMENTATION SCM
+scm_array_handle_ref (scm_t_array_handle *h, ssize_t p)
+{
+  if (SCM_UNLIKELY (p < 0 && ((size_t)-p) > h->base))
+    /* catch overflow */
+    scm_out_of_range (NULL, scm_from_ssize_t (p));
+  /* perhaps should catch overflow here too */
+  return h->impl->vref (h, h->base + p);
+}
+
+SCM_INLINE_IMPLEMENTATION void
+scm_array_handle_set (scm_t_array_handle *h, ssize_t p, SCM v)
+{
+  if (SCM_UNLIKELY (p < 0 && ((size_t)-p) > h->base))
+    /* catch overflow */
+    scm_out_of_range (NULL, scm_from_ssize_t (p));
+  /* perhaps should catch overflow here too */
+  h->impl->vset (h, h->base + p, v);
+}
+
+#endif
+
 
 SCM_INTERNAL void scm_init_array_handle (void);
 
diff --git a/libguile/array-map.c b/libguile/array-map.c
index c0f0f00..e47fb56 100644
--- a/libguile/array-map.c
+++ b/libguile/array-map.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1996,1998,2000,2001,2004,2005, 2006, 2008, 2009, 2010, 2011, 
2012 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1998, 2000, 2001, 2004, 2005, 2006, 2008, 2009,
+ *   2010, 2011, 2012, 2013 Free Software Foundation, Inc.
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -317,6 +318,23 @@ scm_ramapc (void *cproc_ptr, SCM data, SCM ra0, SCM lra, 
const char *what)
     }
 }
 
+static int
+rafill (SCM dst, SCM fill)
+{
+  long n = (SCM_I_ARRAY_DIMS (dst)->ubnd - SCM_I_ARRAY_DIMS (dst)->lbnd + 1);
+  scm_t_array_handle h;
+  size_t i;
+  ssize_t inc;
+  scm_array_get_handle (SCM_I_ARRAY_V (dst), &h);
+  i = h.base + h.dims[0].lbnd + SCM_I_ARRAY_BASE (dst)*h.dims[0].inc;
+  inc = SCM_I_ARRAY_DIMS (dst)->inc * h.dims[0].inc;
+
+  for (; n-- > 0; i += inc)
+    h.impl->vset (&h, i, fill);
+
+  scm_array_handle_release (&h);
+  return 1;
+}
 
 SCM_DEFINE (scm_array_fill_x, "array-fill!", 2, 0, 0,
            (SCM ra, SCM fill),
@@ -324,47 +342,35 @@ SCM_DEFINE (scm_array_fill_x, "array-fill!", 2, 0, 0,
            "returned is unspecified.")
 #define FUNC_NAME s_scm_array_fill_x
 {
-  scm_ramapc (scm_array_fill_int, fill, ra, SCM_EOL, FUNC_NAME);
+  scm_ramapc (rafill, fill, ra, SCM_EOL, FUNC_NAME);
   return SCM_UNSPECIFIED;
 }
 #undef FUNC_NAME
 
-/* to be used as cproc in scm_ramapc to fill an array dimension with
-   "fill". */
-int 
-scm_array_fill_int (SCM ra, SCM fill, SCM ignore SCM_UNUSED)
-#define FUNC_NAME s_scm_array_fill_x
-{
-  unsigned long i;
-  unsigned long n = SCM_I_ARRAY_DIMS (ra)->ubnd - SCM_I_ARRAY_DIMS (ra)->lbnd 
+ 1;
-  long inc = SCM_I_ARRAY_DIMS (ra)->inc;
-  unsigned long base = SCM_I_ARRAY_BASE (ra);
-
-  ra = SCM_I_ARRAY_V (ra);
-
-  for (i = base; n--; i += inc)
-    GVSET (ra, i, fill);
-
-  return 1;
-}
-#undef FUNC_NAME
-
 
-
-static int 
+static int
 racp (SCM src, SCM dst)
 {
   long n = (SCM_I_ARRAY_DIMS (src)->ubnd - SCM_I_ARRAY_DIMS (src)->lbnd + 1);
-  long inc_d, inc_s = SCM_I_ARRAY_DIMS (src)->inc;
-  unsigned long i_d, i_s = SCM_I_ARRAY_BASE (src);
+  scm_t_array_handle h_s, h_d;
+  size_t i_s, i_d;
+  ssize_t inc_s, inc_d;
+
   dst = SCM_CAR (dst);
-  inc_d = SCM_I_ARRAY_DIMS (dst)->inc;
-  i_d = SCM_I_ARRAY_BASE (dst);
-  src = SCM_I_ARRAY_V (src);
-  dst = SCM_I_ARRAY_V (dst);
+  scm_array_get_handle (SCM_I_ARRAY_V (src), &h_s);
+  scm_array_get_handle (SCM_I_ARRAY_V (dst), &h_d);
+
+  i_s = h_s.base + h_s.dims[0].lbnd + SCM_I_ARRAY_BASE (src) * h_s.dims[0].inc;
+  i_d = h_d.base + h_d.dims[0].lbnd + SCM_I_ARRAY_BASE (dst) * h_d.dims[0].inc;
+  inc_s = SCM_I_ARRAY_DIMS (src)->inc * h_s.dims[0].inc;
+  inc_d = SCM_I_ARRAY_DIMS (dst)->inc * h_d.dims[0].inc;
 
   for (; n-- > 0; i_s += inc_s, i_d += inc_d)
-    GVSET (dst, i_d, GVREF (src, i_s));
+    h_d.impl->vset (&h_d, i_d, h_s.impl->vref (&h_s, i_s));
+
+  scm_array_handle_release (&h_d);
+  scm_array_handle_release (&h_s);
+
   return 1;
 }
 
@@ -385,8 +391,28 @@ SCM_DEFINE (scm_array_copy_x, "array-copy!", 2, 0, 0,
 }
 #undef FUNC_NAME
 
-/* Functions callable by ARRAY-MAP! */
 
+#if SCM_ENABLE_DEPRECATED == 1
+
+/* to be used as cproc in scm_ramapc to fill an array dimension with
+   "fill". */
+int
+scm_array_fill_int (SCM ra, SCM fill, SCM ignore SCM_UNUSED)
+{
+  unsigned long i;
+  unsigned long n = SCM_I_ARRAY_DIMS (ra)->ubnd - SCM_I_ARRAY_DIMS (ra)->lbnd 
+ 1;
+  long inc = SCM_I_ARRAY_DIMS (ra)->inc;
+  unsigned long base = SCM_I_ARRAY_BASE (ra);
+
+  ra = SCM_I_ARRAY_V (ra);
+
+  for (i = base; n--; i += inc)
+    GVSET (ra, i, fill);
+
+  return 1;
+}
+
+/* Functions callable by ARRAY-MAP! */
 
 int
 scm_ra_eqp (SCM ra0, SCM ras)
@@ -628,37 +654,52 @@ scm_array_identity (SCM dst, SCM src)
   return racp (SCM_CAR (src), scm_cons (dst, SCM_EOL));
 }
 
+#endif /* SCM_ENABLE_DEPRECATED */
 
-
-static int 
+static int
 ramap (SCM ra0, SCM proc, SCM ras)
 {
-  long i = SCM_I_ARRAY_DIMS (ra0)->lbnd;
-  long inc = SCM_I_ARRAY_DIMS (ra0)->inc;
-  long n = SCM_I_ARRAY_DIMS (ra0)->ubnd;
-  long base = SCM_I_ARRAY_BASE (ra0) - i * inc;
-  ra0 = SCM_I_ARRAY_V (ra0);
+  ssize_t i = SCM_I_ARRAY_DIMS (ra0)->lbnd;
+  size_t n = SCM_I_ARRAY_DIMS (ra0)->ubnd - i + 1;
+
+  scm_t_array_handle h0;
+  size_t i0, i0end;
+  ssize_t inc0;
+  scm_array_get_handle (SCM_I_ARRAY_V (ra0), &h0);
+  i0 = h0.base + h0.dims[0].lbnd + SCM_I_ARRAY_BASE (ra0)*h0.dims[0].inc;
+  inc0 = SCM_I_ARRAY_DIMS (ra0)->inc * h0.dims[0].inc;
+  i0end = i0 + n*inc0;
   if (scm_is_null (ras))
-    for (; i <= n; i++)
-      GVSET (ra0, i*inc+base, scm_call_0 (proc));
+    for (; i0 < i0end; i0 += inc0)
+      h0.impl->vset (&h0, i0, scm_call_0 (proc));
   else
     {
       SCM ra1 = SCM_CAR (ras);
-      SCM args;
-      unsigned long k, i1 = SCM_I_ARRAY_BASE (ra1);
-      long inc1 = SCM_I_ARRAY_DIMS (ra1)->inc;
-      ra1 = SCM_I_ARRAY_V (ra1);
-      ras = scm_vector (SCM_CDR (ras));
-      
-      for (; i <= n; i++, i1 += inc1)
-       {
-         args = SCM_EOL;
-         for (k = scm_c_vector_length (ras); k--;)
-           args = scm_cons (GVREF (scm_c_vector_ref (ras, k), i), args);
-         args = scm_cons (GVREF (ra1, i1), args);
-         GVSET (ra0, i*inc+base, scm_apply_0 (proc, args));
-       }
+      scm_t_array_handle h1;
+      size_t i1;
+      ssize_t inc1;
+      scm_array_get_handle (SCM_I_ARRAY_V (ra1), &h1);
+      i1 = h1.base + h1.dims[0].lbnd + SCM_I_ARRAY_BASE (ra1)*h1.dims[0].inc;
+      inc1 = SCM_I_ARRAY_DIMS (ra1)->inc * h1.dims[0].inc;
+      ras = SCM_CDR (ras);
+      if (scm_is_null (ras))
+          for (; i0 < i0end; i0 += inc0, i1 += inc1)
+            h0.impl->vset (&h0, i0, scm_call_1 (proc, h1.impl->vref (&h1, 
i1)));
+      else
+        {
+          ras = scm_vector (ras);
+          for (; i0 < i0end; i0 += inc0, i1 += inc1, ++i)
+            {
+              SCM args = SCM_EOL;
+              unsigned long k;
+              for (k = scm_c_vector_length (ras); k--;)
+                args = scm_cons (GVREF (scm_c_vector_ref (ras, k), i), args);
+              h0.impl->vset (&h0, i0, scm_apply_1 (proc, h1.impl->vref (&h1, 
i1), args));
+            }
+        }
+      scm_array_handle_release (&h1);
     }
+  scm_array_handle_release (&h0);
   return 1;
 }
 
@@ -691,36 +732,35 @@ SCM_DEFINE (scm_array_map_x, "array-map!", 2, 0, 1,
 static int
 rafe (SCM ra0, SCM proc, SCM ras)
 {
-  long i = SCM_I_ARRAY_DIMS (ra0)->lbnd;
-  unsigned long i0 = SCM_I_ARRAY_BASE (ra0);
-  long inc0 = SCM_I_ARRAY_DIMS (ra0)->inc;
-  long n = SCM_I_ARRAY_DIMS (ra0)->ubnd;
-  ra0 = SCM_I_ARRAY_V (ra0);
+  ssize_t i = SCM_I_ARRAY_DIMS (ra0)->lbnd;
+  size_t n = SCM_I_ARRAY_DIMS (ra0)->ubnd - i + 1;
+
+  scm_t_array_handle h0;
+  size_t i0, i0end;
+  ssize_t inc0;
+  scm_array_get_handle (SCM_I_ARRAY_V (ra0), &h0);
+  i0 = h0.base + h0.dims[0].lbnd + SCM_I_ARRAY_BASE (ra0)*h0.dims[0].inc;
+  inc0 = SCM_I_ARRAY_DIMS (ra0)->inc * h0.dims[0].inc;
+  i0end = i0 + n*inc0;
   if (scm_is_null (ras))
-    for (; i <= n; i++, i0 += inc0)
-      scm_call_1 (proc, GVREF (ra0, i0));
+    for (; i0 < i0end; i0 += inc0)
+      scm_call_1 (proc, h0.impl->vref (&h0, i0));
   else
     {
-      SCM ra1 = SCM_CAR (ras);
-      SCM args;
-      unsigned long k, i1 = SCM_I_ARRAY_BASE (ra1);
-      long inc1 = SCM_I_ARRAY_DIMS (ra1)->inc;
-      ra1 = SCM_I_ARRAY_V (ra1);
-      ras = scm_vector (SCM_CDR (ras));
-
-      for (; i <= n; i++, i0 += inc0, i1 += inc1)
-       {
-         args = SCM_EOL;
-         for (k = scm_c_vector_length (ras); k--;)
-           args = scm_cons (GVREF (scm_c_vector_ref (ras, k), i), args);
-         args = scm_cons2 (GVREF (ra0, i0), GVREF (ra1, i1), args);
-         scm_apply_0 (proc, args);
-       }
+      ras = scm_vector (ras);
+      for (; i0 < i0end; i0 += inc0, ++i)
+        {
+          SCM args = SCM_EOL;
+          unsigned long k;
+          for (k = scm_c_vector_length (ras); k--;)
+            args = scm_cons (GVREF (scm_c_vector_ref (ras, k), i), args);
+          scm_apply_1 (proc, h0.impl->vref (&h0, i0), args);
+        }
     }
+  scm_array_handle_release (&h0);
   return 1;
 }
 
-
 SCM_DEFINE (scm_array_for_each, "array-for-each", 2, 0, 1,
            (SCM proc, SCM ra0, SCM lra),
            "Apply @var{proc} to each tuple of elements of @var{ra0} @dots{}\n"
diff --git a/libguile/array-map.h b/libguile/array-map.h
index 43d2a92..b0592d8 100644
--- a/libguile/array-map.h
+++ b/libguile/array-map.h
@@ -4,7 +4,7 @@
 #define SCM_ARRAY_MAP_H
 
 /* Copyright (C) 1995, 1996, 1997, 2000, 2006, 2008, 2009, 2010,
- *   2011 Free Software Foundation, Inc.
+ *   2011, 2013 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -31,25 +31,30 @@
 SCM_API int scm_ra_matchp (SCM ra0, SCM ras);
 SCM_API int scm_ramapc (void *cproc, SCM data, SCM ra0, SCM lra,
                        const char *what);
-SCM_API int scm_array_fill_int (SCM ra, SCM fill, SCM ignore);
 SCM_API SCM scm_array_fill_x (SCM ra, SCM fill);
 SCM_API SCM scm_array_copy_x (SCM src, SCM dst);
-SCM_API int scm_ra_eqp (SCM ra0, SCM ras);
-SCM_API int scm_ra_lessp (SCM ra0, SCM ras);
-SCM_API int scm_ra_leqp (SCM ra0, SCM ras);
-SCM_API int scm_ra_grp (SCM ra0, SCM ras);
-SCM_API int scm_ra_greqp (SCM ra0, SCM ras);
-SCM_API int scm_ra_sum (SCM ra0, SCM ras);
-SCM_API int scm_ra_difference (SCM ra0, SCM ras);
-SCM_API int scm_ra_product (SCM ra0, SCM ras);
-SCM_API int scm_ra_divide (SCM ra0, SCM ras);
-SCM_API int scm_array_identity (SCM src, SCM dst);
 SCM_API SCM scm_array_map_x (SCM ra0, SCM proc, SCM lra);
 SCM_API SCM scm_array_for_each (SCM proc, SCM ra0, SCM lra);
 SCM_API SCM scm_array_index_map_x (SCM ra, SCM proc);
 SCM_API SCM scm_array_equal_p (SCM ra0, SCM ra1);
 SCM_INTERNAL void scm_init_array_map (void);
 
+#if SCM_ENABLE_DEPRECATED == 1
+
+SCM_DEPRECATED int scm_array_fill_int (SCM ra, SCM fill, SCM ignore);
+SCM_DEPRECATED int scm_ra_eqp (SCM ra0, SCM ras);
+SCM_DEPRECATED int scm_ra_lessp (SCM ra0, SCM ras);
+SCM_DEPRECATED int scm_ra_leqp (SCM ra0, SCM ras);
+SCM_DEPRECATED int scm_ra_grp (SCM ra0, SCM ras);
+SCM_DEPRECATED int scm_ra_greqp (SCM ra0, SCM ras);
+SCM_DEPRECATED int scm_ra_sum (SCM ra0, SCM ras);
+SCM_DEPRECATED int scm_ra_difference (SCM ra0, SCM ras);
+SCM_DEPRECATED int scm_ra_product (SCM ra0, SCM ras);
+SCM_DEPRECATED int scm_ra_divide (SCM ra0, SCM ras);
+SCM_DEPRECATED int scm_array_identity (SCM src, SCM dst);
+
+#endif  /* SCM_ENABLE_DEPRECATED == 1 */
+
 #endif  /* SCM_ARRAY_MAP_H */
 
 /*
diff --git a/libguile/bdw-gc.h b/libguile/bdw-gc.h
index 2e1fce2..7aa757f 100644
--- a/libguile/bdw-gc.h
+++ b/libguile/bdw-gc.h
@@ -1,7 +1,7 @@
 #ifndef SCM_BDW_GC_H
 #define SCM_BDW_GC_H
 
-/* Copyright (C) 2006, 2008, 2009, 2011, 2012 Free Software Foundation, Inc.
+/* Copyright (C) 2006, 2008, 2009, 2011, 2012, 2013 Free Software Foundation, 
Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -37,6 +37,11 @@
    routines.  */
 # define GC_NO_THREAD_REDIRECTS 1
 
+#ifdef __MINGW32__
+/* Rely on pthreads-w32.  */
+#define GC_WIN32_PTHREADS
+#endif
+
 #endif
 
 #include <gc/gc.h>
diff --git a/libguile/c-tokenize.lex b/libguile/c-tokenize.lex
index dc72257..856224e 100644
--- a/libguile/c-tokenize.lex
+++ b/libguile/c-tokenize.lex
@@ -14,7 +14,8 @@ FLOQUAL               (f|F|l|L)
 INTQUAL                (l|L|ll|LL|lL|Ll|u|U)
 
 %{
-    
+#include <config.h>
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/libguile/debug.c b/libguile/debug.c
index 87513bf..9e63f2c 100644
--- a/libguile/debug.c
+++ b/libguile/debug.c
@@ -1,5 +1,5 @@
 /* Debugging extensions for Guile
- * Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2003, 2006, 2008, 
2009, 2010, 2011, 2012 Free Software Foundation
+ * Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2003, 2006, 2008, 
2009, 2010, 2011, 2012, 2013 Free Software Foundation
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -115,45 +115,6 @@ SCM_DEFINE (scm_debug_options, "debug-options-interface", 
0, 1, 0,
 }
 #undef FUNC_NAME
 
-
-SCM_SYMBOL (scm_sym_source, "source");
-
-SCM_DEFINE (scm_procedure_name, "procedure-name", 1, 0, 0, 
-            (SCM proc),
-           "Return the name of the procedure @var{proc}")
-#define FUNC_NAME s_scm_procedure_name
-{
-  SCM_VALIDATE_PROC (1, proc);
-  while (SCM_STRUCTP (proc) && SCM_STRUCT_APPLICABLE_P (proc))
-    proc = SCM_STRUCT_PROCEDURE (proc);
-  return scm_procedure_property (proc, scm_sym_name);
-}
-#undef FUNC_NAME
-
-SCM_DEFINE (scm_procedure_source, "procedure-source", 1, 0, 0, 
-            (SCM proc),
-           "Return the source of the procedure @var{proc}.")
-#define FUNC_NAME s_scm_procedure_source
-{
-  SCM src;
-  SCM_VALIDATE_PROC (1, proc);
-
-  do 
-    {
-      src = scm_procedure_property (proc, scm_sym_source);
-      if (scm_is_true (src))
-        return src;
-
-      if (SCM_STRUCTP (proc) && SCM_STRUCT_APPLICABLE_P (proc)
-          && SCM_HEAP_OBJECT_P ((proc = SCM_STRUCT_PROCEDURE (proc))))
-        continue;
-    }
-  while (0);
-
-  return SCM_BOOL_F;
-}
-#undef FUNC_NAME
-
 
 
 
@@ -202,10 +163,14 @@ SCM_DEFINE (scm_debug_hang, "debug-hang", 0, 1, 0,
 SCM
 scm_local_eval (SCM exp, SCM env)
 {
-  static SCM local_eval_var = SCM_BOOL_F;
+  static SCM local_eval_var = SCM_UNDEFINED;
+  static scm_i_pthread_mutex_t local_eval_var_mutex
+    = SCM_I_PTHREAD_MUTEX_INITIALIZER;
 
-  if (scm_is_false (local_eval_var))
+  scm_i_scm_pthread_mutex_lock (&local_eval_var_mutex);
+  if (SCM_UNBNDP (local_eval_var))
     local_eval_var = scm_c_public_variable ("ice-9 local-eval", "local-eval");
+  scm_i_pthread_mutex_unlock (&local_eval_var_mutex);
 
   return scm_call_2 (SCM_VARIABLE_REF (local_eval_var), exp, env);
 }
diff --git a/libguile/debug.h b/libguile/debug.h
index 362d9b7..e535a6a 100644
--- a/libguile/debug.h
+++ b/libguile/debug.h
@@ -3,7 +3,7 @@
 #ifndef SCM_DEBUG_H
 #define SCM_DEBUG_H
 
-/* Copyright (C) 
1995,1996,1998,1999,2000,2001,2002,2004,2008,2009,2010,2011,2012
+/* Copyright (C) 
1995,1996,1998,1999,2000,2001,2002,2004,2008,2009,2010,2011,2012,2013
  * Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
@@ -44,8 +44,6 @@ typedef union scm_t_debug_info
 SCM_API SCM scm_local_eval (SCM exp, SCM env);
 
 SCM_API SCM scm_reverse_lookup (SCM env, SCM data);
-SCM_API SCM scm_procedure_source (SCM proc);
-SCM_API SCM scm_procedure_name (SCM proc);
 SCM_API SCM scm_debug_options (SCM setting);
 
 SCM_INTERNAL void scm_init_debug (void);
diff --git a/libguile/deprecated.c b/libguile/deprecated.c
index cf44024..cca1454 100644
--- a/libguile/deprecated.c
+++ b/libguile/deprecated.c
@@ -2,7 +2,7 @@
    deprecate something, move it here when that is feasible.
 */
 
-/* Copyright (C) 2003, 2004, 2006, 2008, 2009, 2010, 2011, 2012 Free Software 
Foundation, Inc.
+/* Copyright (C) 2003, 2004, 2006, 2008, 2009, 2010, 2011, 2012, 2013 Free 
Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -79,6 +79,88 @@ scm_immutable_double_cell (scm_t_bits car, scm_t_bits cbr,
 
 
 
+SCM_DEFINE (scm_generalized_vector_p, "generalized-vector?", 1, 0, 0,
+           (SCM obj),
+           "Return @code{#t} if @var{obj} is a vector, string,\n"
+           "bitvector, or uniform numeric vector.")
+#define FUNC_NAME s_scm_generalized_vector_p
+{
+  scm_c_issue_deprecation_warning
+    ("generalized-vector? is deprecated.  Use array? and check the "
+     "array-rank instead.");
+  return scm_from_bool (scm_is_generalized_vector (obj));
+}
+#undef FUNC_NAME
+
+SCM_DEFINE (scm_generalized_vector_length, "generalized-vector-length", 1, 0, 
0,
+           (SCM v),
+           "Return the length of the generalized vector @var{v}.")
+#define FUNC_NAME s_scm_generalized_vector_length
+{
+  scm_c_issue_deprecation_warning
+    ("generalized-vector-length is deprecated.  Use array-length instead.");
+  return scm_from_size_t (scm_c_generalized_vector_length (v));
+}
+#undef FUNC_NAME
+
+SCM_DEFINE (scm_generalized_vector_ref, "generalized-vector-ref", 2, 0, 0,
+           (SCM v, SCM idx),
+           "Return the element at index @var{idx} of the\n"
+           "generalized vector @var{v}.")
+#define FUNC_NAME s_scm_generalized_vector_ref
+{
+  scm_c_issue_deprecation_warning
+    ("generalized-vector-ref is deprecated.  Use array-ref instead.");
+  return scm_c_generalized_vector_ref (v, scm_to_size_t (idx));
+}
+#undef FUNC_NAME
+
+SCM_DEFINE (scm_generalized_vector_set_x, "generalized-vector-set!", 3, 0, 0,
+           (SCM v, SCM idx, SCM val),
+           "Set the element at index @var{idx} of the\n"
+           "generalized vector @var{v} to @var{val}.")
+#define FUNC_NAME s_scm_generalized_vector_set_x
+{
+  scm_c_issue_deprecation_warning
+    ("generalized-vector-set! is deprecated.  Use array-set! instead.  "
+     "Note the change in argument order!");
+  scm_c_generalized_vector_set_x (v, scm_to_size_t (idx), val);
+  return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+
+SCM_DEFINE (scm_generalized_vector_to_list, "generalized-vector->list", 1, 0, 
0,
+           (SCM v),
+           "Return a new list whose elements are the elements of the\n"
+           "generalized vector @var{v}.")
+#define FUNC_NAME s_scm_generalized_vector_to_list
+{
+  /* FIXME: This duplicates `array_to_list'.  */
+  SCM ret = SCM_EOL;
+  long inc;
+  ssize_t pos, i;
+  scm_t_array_handle h;
+
+  scm_c_issue_deprecation_warning
+    ("generalized-vector->list is deprecated.  Use array->list instead.");
+
+  scm_generalized_vector_get_handle (v, &h);
+
+  i = h.dims[0].ubnd - h.dims[0].lbnd + 1;
+  inc = h.dims[0].inc;
+  pos = (i - 1) * inc;
+
+  for (; i > 0; i--, pos -= inc)
+    ret = scm_cons (h.impl->vref (&h, h.base + pos), ret);
+
+  scm_array_handle_release (&h);
+  return ret;
+}
+#undef FUNC_NAME
+
+
+
+
 void
 scm_i_init_deprecated ()
 {
diff --git a/libguile/error.c b/libguile/error.c
index 790ed05..0df4c73 100644
--- a/libguile/error.c
+++ b/libguile/error.c
@@ -1,5 +1,5 @@
 /* Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2004, 2006, 2010,
- *   2012 Free Software Foundation, Inc.
+ *   2012, 2013 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -100,17 +100,6 @@ SCM_DEFINE (scm_error_scm, "scm-error", 5, 0, 0,
 }
 #undef FUNC_NAME
 
-#if defined __MINGW32__ && defined HAVE_NETWORKING
-# include "win32-socket.h"
-# define SCM_I_STRERROR(err) \
-    ((err >= WSABASEERR) ? scm_i_socket_strerror (err) : strerror (err))
-# define SCM_I_ERRNO() \
-    (errno ? errno : scm_i_socket_errno ())
-#else
-# define SCM_I_STRERROR(err) strerror (err)
-# define SCM_I_ERRNO() errno
-#endif /* __MINGW32__ */
-
 /* strerror may not be thread safe, for instance in glibc (version 2.3.2) an
    error number not among the known values results in a string like "Unknown
    error 9999" formed in a static buffer, which will be overwritten by a
@@ -136,7 +125,7 @@ SCM_DEFINE (scm_strerror, "strerror", 1, 0, 0,
   scm_dynwind_begin (0);
   scm_i_dynwind_pthread_mutex_lock (&scm_i_misc_mutex);
 
-  ret = scm_from_locale_string (SCM_I_STRERROR (scm_to_int (err)));
+  ret = scm_from_locale_string (strerror (scm_to_int (err)));
 
   scm_dynwind_end ();
   return ret;
@@ -147,7 +136,7 @@ SCM_GLOBAL_SYMBOL (scm_system_error_key, "system-error");
 void
 scm_syserror (const char *subr)
 {
-  SCM err = scm_from_int (SCM_I_ERRNO ());
+  SCM err = scm_from_int (errno);
 
   /* It could be that we're getting here because the syscall was
      interrupted by a signal.  In that case a signal handler might have
diff --git a/libguile/filesys.c b/libguile/filesys.c
index 3d5b1fb..1893c02 100644
--- a/libguile/filesys.c
+++ b/libguile/filesys.c
@@ -1,5 +1,5 @@
 /* Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2006,
- *   2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+ *   2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -45,7 +45,6 @@
 #include "libguile/feature.h"
 #include "libguile/fports.h"
 #include "libguile/private-gc.h"  /* for SCM_MAX */
-#include "libguile/iselect.h"
 #include "libguile/strings.h"
 #include "libguile/vectors.h"
 #include "libguile/dynwind.h"
@@ -81,9 +80,7 @@
 #include <libc.h>
 #endif
 
-#ifdef HAVE_SYS_SELECT_H
 #include <sys/select.h>
-#endif
 
 #ifdef HAVE_STRING_H
 #include <string.h>
@@ -101,6 +98,18 @@
 
 #define NAMLEN(dirent)  strlen ((dirent)->d_name)
 
+#ifdef HAVE_SYS_SENDFILE_H
+# include <sys/sendfile.h>
+#endif
+
+/* Glibc's `sendfile' function.  */
+#define sendfile_or_sendfile64                 \
+  CHOOSE_LARGEFILE (sendfile, sendfile64)
+
+#include <full-read.h>
+#include <full-write.h>
+
+
 /* Some more definitions for the native Windows port. */
 #ifdef __MINGW32__
 # define fsync(fd) _commit (fd)
@@ -435,30 +444,17 @@ scm_stat2scm (struct stat_or_stat64 *stat_temp)
   return ans;
 }
 
-#ifdef __MINGW32__
-/*
- * Try getting the appropiate stat buffer for a given file descriptor
- * under Windows. It differentiates between file, pipe and socket 
- * descriptors.
- */
-static int fstat_Win32 (int fdes, struct stat *buf)
+static int
+is_file_name_separator (SCM c)
 {
-  int error, optlen = sizeof (int);
-
-  memset (buf, 0, sizeof (struct stat));
-
-  /* Is this a socket ? */
-  if (getsockopt (fdes, SOL_SOCKET, SO_ERROR, (void *) &error, &optlen) >= 0)
-    {
-      buf->st_mode = _S_IREAD | _S_IWRITE | _S_IEXEC;
-      buf->st_nlink = 1;
-      buf->st_atime = buf->st_ctime = buf->st_mtime = time (NULL);
-      return 0;
-    }
-  /* Maybe a regular file or pipe ? */
-  return fstat (fdes, buf);
+  if (scm_is_eq (c, SCM_MAKE_CHAR ('/')))
+    return 1;
+#ifdef __MINGW32__
+  if (scm_is_eq (c, SCM_MAKE_CHAR ('\\')))
+    return 1;
+#endif
+  return 0;
 }
-#endif /* __MINGW32__ */
 
 SCM_DEFINE (scm_stat, "stat", 1, 1, 0, 
             (SCM object, SCM exception_on_error),
@@ -532,21 +528,11 @@ SCM_DEFINE (scm_stat, "stat", 1, 1, 0,
 
   if (scm_is_integer (object))
     {
-#ifdef __MINGW32__
-      SCM_SYSCALL (rv = fstat_Win32 (scm_to_int (object), &stat_temp));
-#else
       SCM_SYSCALL (rv = fstat_or_fstat64 (scm_to_int (object), &stat_temp));
-#endif
     }
   else if (scm_is_string (object))
     {
       char *file = scm_to_locale_string (object);
-#ifdef __MINGW32__
-      char *p;
-      p = file + strlen (file) - 1;
-      while (p > file && (*p == '/' || *p == '\\'))
-       *p-- = '\0';
-#endif
       SCM_SYSCALL (rv = stat_or_stat64 (file, &stat_temp));
       free (file);
     }
@@ -555,11 +541,7 @@ SCM_DEFINE (scm_stat, "stat", 1, 1, 0,
       object = SCM_COERCE_OUTPORT (object);
       SCM_VALIDATE_OPFPORT (1, object);
       fdes = SCM_FPORT_FDES (object);
-#ifdef __MINGW32__
-      SCM_SYSCALL (rv = fstat_Win32 (fdes, &stat_temp));
-#else
       SCM_SYSCALL (rv = fstat_or_fstat64 (fdes, &stat_temp));
-#endif
     }
 
   if (rv == -1)
@@ -653,15 +635,13 @@ SCM_DEFINE (scm_chdir, "chdir", 1, 0, 0,
 
 
 
-#ifdef HAVE_SELECT
-
 /* check that element is a port or file descriptor.  if it's a port
    and its buffer is ready for use, add it to the ports_ready list.
    otherwise add its file descriptor to *set.  the type of list can be
    determined from pos: SCM_ARG1 for reads, SCM_ARG2 for writes,
    SCM_ARG3 for excepts.  */
 static int
-set_element (SELECT_TYPE *set, SCM *ports_ready, SCM element, int pos)
+set_element (fd_set *set, SCM *ports_ready, SCM element, int pos)
 {
   int fd;
 
@@ -707,7 +687,7 @@ set_element (SELECT_TYPE *set, SCM *ports_ready, SCM 
element, int pos)
    determined from pos: SCM_ARG1 for reads, SCM_ARG2 for writes,
    SCM_ARG3 for excepts.  */
 static int
-fill_select_type (SELECT_TYPE *set, SCM *ports_ready, SCM list_or_vec, int pos)
+fill_select_type (fd_set *set, SCM *ports_ready, SCM list_or_vec, int pos)
 {
   int max_fd = 0;
 
@@ -742,7 +722,7 @@ fill_select_type (SELECT_TYPE *set, SCM *ports_ready, SCM 
list_or_vec, int pos)
 /* if element (a file descriptor or port) appears in *set, cons it to
    list.  return list.  */
 static SCM
-get_element (SELECT_TYPE *set, SCM element, SCM list)
+get_element (fd_set *set, SCM element, SCM list)
 {
   int fd;
 
@@ -768,7 +748,7 @@ get_element (SELECT_TYPE *set, SCM element, SCM list)
    *set and appending them to ports_ready.  result is converted to a
    vector if list_or_vec is a vector.  */
 static SCM 
-retrieve_select_type (SELECT_TYPE *set, SCM ports_ready, SCM list_or_vec)
+retrieve_select_type (fd_set *set, SCM ports_ready, SCM list_or_vec)
 {
   SCM answer_list = ports_ready;
 
@@ -829,9 +809,9 @@ SCM_DEFINE (scm_select, "select", 3, 2, 0,
 {
   struct timeval timeout;
   struct timeval * time_ptr;
-  SELECT_TYPE read_set;
-  SELECT_TYPE write_set;
-  SELECT_TYPE except_set;
+  fd_set read_set;
+  fd_set write_set;
+  fd_set except_set;
   int read_count;
   int write_count;
   int except_count;
@@ -922,9 +902,9 @@ SCM_DEFINE (scm_select, "select", 3, 2, 0,
     }
 
   {
-    int rv = scm_std_select (max_fd + 1,
-                            &read_set, &write_set, &except_set,
-                            time_ptr);
+    int rv = select (max_fd + 1,
+                     &read_set, &write_set, &except_set,
+                     time_ptr);
     if (rv < 0)
       SCM_SYSERROR;
   }
@@ -933,7 +913,6 @@ SCM_DEFINE (scm_select, "select", 3, 2, 0,
                     retrieve_select_type (&except_set, SCM_EOL, excepts));
 }
 #undef FUNC_NAME
-#endif /* HAVE_SELECT */
 
 
 
@@ -1095,15 +1074,11 @@ SCM_DEFINE (scm_copy_file, "copy-file", 2, 0, 0,
   c_newfile = scm_to_locale_string (newfile);
   scm_dynwind_free (c_newfile);
 
-  oldfd = open_or_open64 (c_oldfile, O_RDONLY);
+  oldfd = open_or_open64 (c_oldfile, O_RDONLY | O_BINARY);
   if (oldfd == -1)
     SCM_SYSERROR;
 
-#ifdef __MINGW32__
-  SCM_SYSCALL (rv = fstat_Win32 (oldfd, &oldstat));
-#else
   SCM_SYSCALL (rv = fstat_or_fstat64 (oldfd, &oldstat));
-#endif
   if (rv == -1)
     goto err_close_oldfd;
 
@@ -1133,6 +1108,117 @@ SCM_DEFINE (scm_copy_file, "copy-file", 2, 0, 0,
 }
 #undef FUNC_NAME
 
+SCM_DEFINE (scm_sendfile, "sendfile", 3, 1, 0,
+           (SCM out, SCM in, SCM count, SCM offset),
+           "Send @var{count} bytes from @var{in} to @var{out}, both of which "
+           "must be either open file ports or file descriptors.  When "
+           "@var{offset} is omitted, start reading from @var{in}'s current "
+           "position; otherwise, start reading at @var{offset}.  Return "
+           "the number of bytes actually sent.")
+#define FUNC_NAME s_scm_sendfile
+{
+#define VALIDATE_FD_OR_PORT(cvar, svar, pos)   \
+  if (scm_is_integer (svar))                   \
+    cvar = scm_to_int (svar);                  \
+  else                                         \
+    {                                          \
+      SCM_VALIDATE_OPFPORT (pos, svar);                \
+      scm_flush (svar);                                \
+      cvar = SCM_FPORT_FDES (svar);            \
+    }
+
+  ssize_t result SCM_UNUSED;
+  size_t c_count, total = 0;
+  scm_t_off c_offset;
+  int in_fd, out_fd;
+
+  VALIDATE_FD_OR_PORT (out_fd, out, 1);
+  VALIDATE_FD_OR_PORT (in_fd, in, 2);
+  c_count = scm_to_size_t (count);
+  c_offset = SCM_UNBNDP (offset) ? 0 : scm_to_off_t (offset);
+
+#if defined HAVE_SYS_SENDFILE_H && defined HAVE_SENDFILE
+  /* The Linux-style sendfile(2), which is different from the BSD-style.  */
+
+  {
+    off_t *offset_ptr;
+
+    offset_ptr = SCM_UNBNDP (offset) ? NULL : &c_offset;
+
+    /* On Linux, when OUT_FD is a file, everything is transferred at once and
+       RESULT == C_COUNT.  However, when OUT_FD is a pipe or other "slow"
+       device, fewer bytes may be transferred, hence the loop.  RESULT == 0
+       means EOF on IN_FD, so leave the loop in that case.  */
+    do
+      {
+       result = sendfile_or_sendfile64 (out_fd, in_fd, offset_ptr,
+                                        c_count - total);
+       if (result > 0)
+         /* At this point, either OFFSET_PTR is non-NULL and it has been
+            updated to the current offset in IN_FD, or it is NULL and IN_FD's
+            offset has been updated.  */
+         total += result;
+       else if (result < 0 && (errno == EINTR || errno == EAGAIN))
+         /* Keep going.  */
+         result = 1;
+      }
+    while (total < c_count && result > 0);
+  }
+
+  /* Quoting the Linux man page: "In Linux kernels before 2.6.33, out_fd
+     must refer to a socket.  Since Linux 2.6.33 it can be any file."
+     Fall back to read(2) and write(2) when such an error occurs.  */
+  if (result < 0 && errno != EINVAL && errno != ENOSYS)
+    SCM_SYSERROR;
+  else if (result < 0)
+#endif
+  {
+    char buf[8192];
+    size_t left;
+    int reached_eof = 0;
+
+    if (!SCM_UNBNDP (offset))
+      {
+       if (SCM_PORTP (in))
+         scm_seek (in, scm_from_off_t (c_offset), scm_from_int (SEEK_SET));
+       else
+         {
+           if (lseek_or_lseek64 (in_fd, c_offset, SEEK_SET) < 0)
+             SCM_SYSERROR;
+         }
+      }
+
+    for (total = 0, left = c_count; total < c_count && !reached_eof; )
+      {
+       size_t asked, obtained, written;
+
+       asked = SCM_MIN (sizeof buf, left);
+       obtained = full_read (in_fd, buf, asked);
+       if (obtained < asked)
+          {
+            if (errno == 0)
+              reached_eof = 1;
+            else
+              SCM_SYSERROR;
+          }
+
+       left -= obtained;
+
+       written = full_write (out_fd, buf, obtained);
+       if (written < obtained)
+         SCM_SYSERROR;
+
+       total += written;
+      }
+
+  }
+
+  return scm_from_size_t (total);
+
+#undef VALIDATE_FD_OR_PORT
+}
+#undef FUNC_NAME
+
 #endif /* HAVE_POSIX */
 
 
@@ -1434,6 +1520,24 @@ SCM_DEFINE (scm_mkstemp, "mkstemp!", 1, 0, 0,
 
 SCM scm_dot_string;
 
+#ifdef __MINGW32__
+SCM_SYMBOL (sym_file_name_convention, "windows");
+#else
+SCM_SYMBOL (sym_file_name_convention, "posix");
+#endif
+
+SCM_INTERNAL SCM scm_system_file_name_convention (void);
+
+SCM_DEFINE (scm_system_file_name_convention,
+            "system-file-name-convention", 0, 0, 0, (void),
+           "Return either @code{posix} or @code{windows}, depending on\n"
+            "what kind of system this Guile is running on.")
+#define FUNC_NAME s_scm_system_file_name_convention
+{
+  return sym_file_name_convention;
+}
+#undef FUNC_NAME
+
 SCM_DEFINE (scm_dirname, "dirname", 1, 0, 0, 
             (SCM filename),
            "Return the directory name component of the file name\n"
@@ -1449,32 +1553,17 @@ SCM_DEFINE (scm_dirname, "dirname", 1, 0, 0,
   len = scm_i_string_length (filename);
 
   i = len - 1;
-#ifdef __MINGW32__
-  while (i >= 0 && (scm_i_string_ref (filename, i) == '/'
-                   || scm_i_string_ref (filename, i) == '\\')) 
-    --i;
-  while (i >= 0 && (scm_i_string_ref (filename, i) != '/'
-                   && scm_i_string_ref (filename, i) != '\\')) 
-    --i;
-  while (i >= 0 && (scm_i_string_ref (filename, i) == '/'
-                   || scm_i_string_ref (filename, i) == '\\')) 
-    --i;
-#else
-  while (i >= 0 && scm_i_string_ref (filename, i) == '/') 
+
+  while (i >= 0 && is_file_name_separator (scm_c_string_ref (filename, i)))
     --i;
-  while (i >= 0 && scm_i_string_ref (filename, i) != '/') 
+  while (i >= 0 && !is_file_name_separator (scm_c_string_ref (filename, i)))
     --i;
-  while (i >= 0 && scm_i_string_ref (filename, i) == '/') 
+  while (i >= 0 && is_file_name_separator (scm_c_string_ref (filename, i)))
     --i;
-#endif /* ndef __MINGW32__ */
+
   if (i < 0)
     {
-#ifdef __MINGW32__
-      if (len > 0 && (scm_i_string_ref (filename, 0) == '/'
-                     || scm_i_string_ref (filename, 0) == '\\'))
-#else
-      if (len > 0 && scm_i_string_ref (filename, 0) == '/')
-#endif /* ndef __MINGW32__ */
+      if (len > 0 && is_file_name_separator (scm_c_string_ref (filename, 0)))
        return scm_c_substring (filename, 0, 1);
       else
        return scm_dot_string;
@@ -1505,14 +1594,8 @@ SCM_DEFINE (scm_basename, "basename", 1, 1, 0,
       j = scm_i_string_length (suffix) - 1;
     }
   i = len - 1;
-#ifdef __MINGW32__
-  while (i >= 0 && (scm_i_string_ref (filename, i) == '/'
-                   || scm_i_string_ref (filename, i) ==  '\\'))
-    --i;
-#else
-  while (i >= 0 && scm_i_string_ref (filename, i) == '/')
+  while (i >= 0 && is_file_name_separator (scm_c_string_ref (filename, i)))
     --i;
-#endif /* ndef __MINGW32__ */
   end = i;
   while (i >= 0 && j >= 0 
         && (scm_i_string_ref (filename, i)
@@ -1523,22 +1606,11 @@ SCM_DEFINE (scm_basename, "basename", 1, 1, 0,
     }
   if (j == -1)
     end = i;
-#ifdef __MINGW32__
-  while (i >= 0 && (scm_i_string_ref (filename, i) != '/'
-                   && scm_i_string_ref (filename, i) != '\\'))
-    --i;
-#else
-  while (i >= 0 && scm_i_string_ref (filename, i) != '/')
+  while (i >= 0 && !is_file_name_separator (scm_c_string_ref (filename, i)))
     --i;
-#endif /* ndef __MINGW32__ */
   if (i == end)
     {
-#ifdef __MINGW32__
-      if (len > 0 && (scm_i_string_ref (filename, 0) ==  '/'
-                     || scm_i_string_ref (filename, 0) ==  '\\'))
-#else
-      if (len > 0 && scm_i_string_ref (filename, 0) == '/')
-#endif /* ndef __MINGW32__ */
+      if (len > 0 && is_file_name_separator (scm_c_string_ref (filename, 0)))
         return scm_c_substring (filename, 0, 1);
       else
        return scm_dot_string;
@@ -1605,14 +1677,7 @@ scm_i_relativize_path (SCM path, SCM in_path)
             will be delimited by single delimiters.  When DIR does not
             have a trailing delimiter, add one to the length to strip
             off the delimiter within SCANON.  */
-         if (
-#ifdef __MINGW32__
-             (scm_i_string_ref (dir, len - 1) != '/'
-              && scm_i_string_ref (dir, len - 1) != '\\')
-#else
-             scm_i_string_ref (dir, len - 1) != '/'
-#endif
-             )
+         if (!is_file_name_separator (scm_c_string_ref (dir, len - 1)))
            len++;
 
          if (scm_c_string_length (scanon) > len)
diff --git a/libguile/filesys.h b/libguile/filesys.h
index c420992..fc66e40 100644
--- a/libguile/filesys.h
+++ b/libguile/filesys.h
@@ -3,7 +3,8 @@
 #ifndef SCM_FILESYS_H
 #define SCM_FILESYS_H
 
-/* Copyright (C) 1995,1997,1998,1999,2000,2001, 2006, 2008, 2009, 2010, 2011 
Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1997, 1998, 1999, 2000, 2001, 2006, 2008, 2009,
+ *   2010, 2011, 2013 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -66,6 +67,7 @@ SCM_API SCM scm_copy_file (SCM oldfile, SCM newfile);
 SCM_API SCM scm_dirname (SCM filename);
 SCM_API SCM scm_basename (SCM filename, SCM suffix);
 SCM_API SCM scm_canonicalize_path (SCM path);
+SCM_API SCM scm_sendfile (SCM out, SCM in, SCM count, SCM offset);
 SCM_INTERNAL SCM scm_i_relativize_path (SCM path, SCM in_path);
 
 SCM_INTERNAL void scm_init_filesys (void);
diff --git a/libguile/fluids.c b/libguile/fluids.c
index 8e36acd..146854b 100644
--- a/libguile/fluids.c
+++ b/libguile/fluids.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1996,1997,2000,2001, 2004, 2006, 2007, 2008, 2009, 2010, 
2011, 2012 Free Software Foundation, Inc.
+/* Copyright (C) 1996,1997,2000,2001, 2004, 2006, 2007, 2008, 2009, 2010,
+ *    2011, 2012, 2013 Free Software Foundation, Inc.
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -304,22 +305,24 @@ apply_thunk (void *thunk)
 size_t
 scm_prepare_fluids (size_t n, SCM *fluids, SCM *values)
 {
-  size_t j = n;
+  size_t j;
 
   /* Ensure that there are no duplicates in the fluids set -- an N^2 operation,
      but N will usually be small, so perhaps that's OK. */
-  while (j--)
+  for (j = n; j--;)
     {
       size_t i;
 
       if (SCM_UNLIKELY (!IS_FLUID (fluids[j])))
         scm_wrong_type_arg ("with-fluids", 0, fluids[j]);
 
-      for (i = 0; i < j; i++)
+      for (i = j; i--;)
         if (scm_is_eq (fluids[i], fluids[j]))
           {
             values[i] = values[j]; /* later bindings win */
             n--;
+            fluids[j] = fluids[n];
+            values[j] = values[n];
             break;
           }
     }
diff --git a/libguile/foreign.c b/libguile/foreign.c
index 47077f7..4f5aa58 100644
--- a/libguile/foreign.c
+++ b/libguile/foreign.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2010, 2011, 2012  Free Software Foundation, Inc.
+/* Copyright (C) 2010, 2011, 2012, 2013  Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -53,6 +53,8 @@ SCM_SYMBOL (sym_unsigned_short, "unsigned-short");
 SCM_SYMBOL (sym_unsigned_int, "unsigned-int");
 SCM_SYMBOL (sym_unsigned_long, "unsigned-long");
 SCM_SYMBOL (sym_size_t, "size_t");
+SCM_SYMBOL (sym_ssize_t, "ssize_t");
+SCM_SYMBOL (sym_ptrdiff_t, "ptrdiff_t");
 
 /* that's for pointers, you know. */
 SCM_SYMBOL (sym_asterisk, "*");
@@ -768,37 +770,40 @@ SCM_DEFINE (scm_pointer_to_procedure, 
"pointer->procedure", 3, 0, 0,
 /* Pre-generate trampolines for less than 10 arguments. */
 
 #ifdef WORDS_BIGENDIAN
-#define OBJCODE_HEADER 0, 0, 0, 8, 0, 0, 0, 40
-#define META_HEADER    0, 0, 0, 32, 0, 0, 0, 0
+#define OBJCODE_HEADER(M) M (0), M (0), M (0), M (8), M (0), M (0), M (0), M 
(40)
+#define META_HEADER(M)    M (0), M (0), M (0), M (32), M (0), M (0), M (0), M 
(0)
 #else
-#define OBJCODE_HEADER 8, 0, 0, 0, 40, 0, 0, 0
-#define META_HEADER    32, 0, 0, 0, 0, 0, 0, 0
+#define OBJCODE_HEADER(M) M (8), M (0), M (0), M (0), M (40), M (0), M (0), M 
(0)
+#define META_HEADER(M)    M (32), M (0), M (0), M (0), M (0), M (0), M (0), M 
(0)
 #endif
 
-#define CODE(nreq)                                                      \
-  OBJCODE_HEADER,                                                       \
-  /* 0 */ scm_op_assert_nargs_ee, 0, nreq, /* assert number of args */  \
-  /* 3 */ scm_op_object_ref, 0, /* push the pair with the cif and the function 
pointer */ \
-  /* 5 */ scm_op_foreign_call, nreq, /* and call (will return value as well) 
*/ \
-  /* 7 */ scm_op_nop,                                                   \
-  /* 8 */ META (3, 7, nreq)
-
-#define META(start, end, nreq)                                         \
-  META_HEADER,                                                          \
-  /* 0 */ scm_op_make_eol, /* bindings */                               \
-  /* 1 */ scm_op_make_eol, /* sources */                                \
-  /* 2 */ scm_op_make_int8, start, scm_op_make_int8, end, /* arity: from ip N 
to ip N */ \
-  /* 6 */ scm_op_make_int8, nreq, /* the arity is N required args */    \
-  /* 8 */ scm_op_list, 0, 3, /* make a list of those 3 vals */         \
-  /* 11 */ scm_op_list, 0, 1, /* and the arities will be a list of that one 
list */ \
-  /* 14 */ scm_op_load_symbol, 0, 0, 4, 'n', 'a', 'm', 'e', /* `name' */ \
-  /* 22 */ scm_op_object_ref, 1, /* the name from the object table */   \
-  /* 24 */ scm_op_cons, /* make a pair for the properties */            \
-  /* 25 */ scm_op_list, 0, 4, /* pack bindings, sources, and arities into list 
*/ \
-  /* 28 */ scm_op_return, /* and return */                              \
-  /* 29 */ scm_op_nop, scm_op_nop, scm_op_nop                           \
+#define GEN_CODE(M, nreq)                                               \
+  OBJCODE_HEADER (M),                                                   \
+  /* 0 */ M (scm_op_assert_nargs_ee), M (0), M (nreq), /* assert number of 
args */ \
+  /* 3 */ M (scm_op_object_ref), M (0), /* push the pair with the cif and the 
function pointer */ \
+  /* 5 */ M (scm_op_foreign_call), M (nreq), /* and call (will return value as 
well) */ \
+  /* 7 */ M (scm_op_nop),                                               \
+  /* 8 */ META (M, 3, 7, nreq)
+
+#define META(M, start, end, nreq)                                       \
+  META_HEADER (M),                                                      \
+  /* 0 */ M (scm_op_make_eol), /* bindings */                           \
+  /* 1 */ M (scm_op_make_eol), /* sources */                            \
+  /* 2 */ M (scm_op_make_int8), M (start), M (scm_op_make_int8), M (end), /* 
arity: from ip N to ip N */ \
+  /* 6 */ M (scm_op_make_int8), M (nreq), /* the arity is N required args */ \
+  /* 8 */ M (scm_op_list), M (0), M (3), /* make a list of those 3 vals */ \
+  /* 11 */ M (scm_op_list), M (0), M (1), /* and the arities will be a list of 
that one list */ \
+  /* 14 */ M (scm_op_load_symbol), M (0), M (0), M (4), M ('n'), M ('a'), M 
('M'), M ('e'), /* `name' */ \
+  /* 22 */ M (scm_op_object_ref), M (1), /* the name from the object table */ \
+  /* 24 */ M (scm_op_cons), /* make a pair for the properties */        \
+  /* 25 */ M (scm_op_list), M (0), M (4), /* pack bindings, sources, and 
arities into list */ \
+  /* 28 */ M (scm_op_return), /* and return */                          \
+  /* 29 */ M (scm_op_nop), M (scm_op_nop), M (scm_op_nop)               \
   /* 32 */
 
+#define M_STATIC(x) (x)
+#define CODE(nreq) GEN_CODE (M_STATIC, nreq)
+
 static const struct
 {
   scm_t_uint64 dummy; /* ensure 8-byte alignment; perhaps there's a better way 
*/
@@ -812,8 +817,28 @@ static const struct
   }
 };
 
-#undef CODE
+static SCM
+make_objcode_trampoline (unsigned int nargs)
+{
+  const int size = sizeof (struct scm_objcode) + 8
+    + sizeof (struct scm_objcode) + 32;
+  SCM bytecode = scm_c_make_bytevector (size);
+  scm_t_uint8 *bytes = (scm_t_uint8 *) SCM_BYTEVECTOR_CONTENTS (bytecode);
+  int i = 0;
+
+#define M_DYNAMIC(x) (bytes[i++] = (x))
+  GEN_CODE (M_DYNAMIC, nargs);
+#undef M_DYNAMIC
+
+  if (i != size)
+    scm_syserror ("make_objcode_trampoline");
+  return scm_bytecode_to_objcode (bytecode, SCM_UNDEFINED);
+}
+
+#undef GEN_CODE
 #undef META
+#undef M_STATIC
+#undef CODE
 #undef OBJCODE_HEADER
 #undef META_HEADER
 
@@ -876,21 +901,43 @@ static const SCM objcode_trampolines[10] = {
   SCM_PACK (objcode_cells.cells+18),
 };
 
+static SCM large_objcode_trampolines = SCM_UNDEFINED;
+static scm_i_pthread_mutex_t large_objcode_trampolines_mutex =
+  SCM_I_PTHREAD_MUTEX_INITIALIZER;
+
 static SCM
-cif_to_procedure (SCM cif, SCM func_ptr)
+get_objcode_trampoline (unsigned int nargs)
 {
-  ffi_cif *c_cif;
-  unsigned int nargs;
-  SCM objcode, table, ret;
-
-  c_cif = (ffi_cif *) SCM_POINTER_VALUE (cif);
-  nargs = c_cif->nargs;
+  SCM objcode;
 
   if (nargs < 10)
     objcode = objcode_trampolines[nargs];
+  else if (nargs < 128)
+    {
+      scm_i_scm_pthread_mutex_lock (&large_objcode_trampolines_mutex);
+      if (SCM_UNBNDP (large_objcode_trampolines))
+        large_objcode_trampolines = scm_c_make_vector (128, SCM_UNDEFINED);
+      objcode = scm_c_vector_ref (large_objcode_trampolines, nargs);
+      if (SCM_UNBNDP (objcode))
+        scm_c_vector_set_x (large_objcode_trampolines, nargs,
+                            objcode = make_objcode_trampoline (nargs));
+      scm_i_pthread_mutex_unlock (&large_objcode_trampolines_mutex);
+    }
   else
-    scm_misc_error ("make-foreign-function", "args >= 10 currently 
unimplemented",
+    scm_misc_error ("make-foreign-function", "args >= 128 currently 
unimplemented",
                     SCM_EOL);
+
+  return objcode;
+}
+
+static SCM
+cif_to_procedure (SCM cif, SCM func_ptr)
+{
+  ffi_cif *c_cif;
+  SCM objcode, table, ret;
+
+  c_cif = (ffi_cif *) SCM_POINTER_VALUE (cif);
+  objcode = get_objcode_trampoline (c_cif->nargs);
   
   table = scm_c_make_vector (2, SCM_UNDEFINED);
   SCM_SIMPLE_VECTOR_SET (table, 0, scm_cons (cif, func_ptr));
@@ -1282,6 +1329,26 @@ scm_init_foreign (void)
 #endif
              );
 
+  scm_define (sym_ssize_t,
+#if SIZEOF_SIZE_T == 8
+             scm_from_uint8 (SCM_FOREIGN_TYPE_INT64)
+#elif SIZEOF_SIZE_T == 4
+             scm_from_uint8 (SCM_FOREIGN_TYPE_INT32)
+#else
+# error unsupported sizeof (ssize_t)
+#endif
+             );
+
+  scm_define (sym_ptrdiff_t,
+#if SCM_SIZEOF_SCM_T_PTRDIFF == 8
+             scm_from_uint8 (SCM_FOREIGN_TYPE_INT64)
+#elif SCM_SIZEOF_SCM_T_PTRDIFF == 4
+             scm_from_uint8 (SCM_FOREIGN_TYPE_INT32)
+#else
+# error unsupported sizeof (scm_t_ptrdiff)
+#endif
+             );
+
   null_pointer = scm_cell (scm_tc7_pointer, 0);
   scm_define (sym_null, null_pointer);
 }
diff --git a/libguile/fports.c b/libguile/fports.c
index 94ce434..13d1dd7 100644
--- a/libguile/fports.c
+++ b/libguile/fports.c
@@ -1,5 +1,5 @@
 /* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
- *   2004, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, 
Inc.
+ *   2004, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software 
Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -28,15 +28,6 @@
 
 #include <stdio.h>
 #include <fcntl.h>
-#include "libguile/_scm.h"
-#include "libguile/strings.h"
-#include "libguile/validate.h"
-#include "libguile/gc.h"
-#include "libguile/posix.h"
-#include "libguile/dynwind.h"
-#include "libguile/hashtab.h"
-
-#include "libguile/fports.h"
 
 #ifdef HAVE_STRING_H
 #include <string.h>
@@ -50,36 +41,23 @@
 #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
 #include <sys/stat.h>
 #endif
-#ifdef HAVE_POLL_H
 #include <poll.h>
-#endif
 #include <errno.h>
 #include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/select.h>
 
 #include <full-write.h>
 
-#include "libguile/iselect.h"
-
-/* Some defines for Windows (native port, not Cygwin). */
-#ifdef __MINGW32__
-# include <sys/stat.h>
-# include <winsock2.h>
-#endif /* __MINGW32__ */
-
-#include <full-write.h>
-
-/* Mingw (version 3.4.5, circa 2006) has ftruncate as an alias for chsize
-   already, but have this code here in case that wasn't so in past versions,
-   or perhaps to help other minimal DOS environments.
-
-   gnulib ftruncate.c has code using fcntl F_CHSIZE and F_FREESP, which
-   might be possibilities if we've got other systems without ftruncate.  */
+#include "libguile/_scm.h"
+#include "libguile/strings.h"
+#include "libguile/validate.h"
+#include "libguile/gc.h"
+#include "libguile/posix.h"
+#include "libguile/dynwind.h"
+#include "libguile/hashtab.h"
 
-#if defined HAVE_CHSIZE && ! defined HAVE_FTRUNCATE
-# define ftruncate(fd, size) chsize (fd, size)
-# undef HAVE_FTRUNCATE
-# define HAVE_FTRUNCATE 1
-#endif
+#include "libguile/fports.h"
 
 #if SIZEOF_OFF_T == SIZEOF_INT
 #define OFF_T_MAX  INT_MAX
@@ -247,8 +225,7 @@ SCM_DEFINE (scm_setvbuf, "setvbuf", 2, 1, 0,
 
   if (ndrained > 0)
     /* Put DRAINED back to PORT.  */
-    while (ndrained-- > 0)
-      scm_unget_byte (drained[ndrained], port);
+    scm_unget_bytes ((unsigned char *) drained, ndrained, port);
 
   return SCM_UNSPECIFIED;
 }
@@ -338,71 +315,35 @@ fport_canonicalize_filename (SCM filename)
     }
 }
 
+/* scm_open_file_with_encoding
+   Return a new port open on a given file.
 
-/* scm_open_file
- * Return a new port open on a given file.
- *
- * The mode string must match the pattern: [rwa+]** which
- * is interpreted in the usual unix way.
- *
- * Return the new port.
- */
-SCM_DEFINE (scm_open_file, "open-file", 2, 0, 0,
-           (SCM filename, SCM mode),
-           "Open the file whose name is @var{filename}, and return a port\n"
-           "representing that file.  The attributes of the port are\n"
-           "determined by the @var{mode} string.  The way in which this is\n"
-           "interpreted is similar to C stdio.  The first character must be\n"
-           "one of the following:\n"
-           "@table @samp\n"
-           "@item r\n"
-           "Open an existing file for input.\n"
-           "@item w\n"
-           "Open a file for output, creating it if it doesn't already exist\n"
-           "or removing its contents if it does.\n"
-           "@item a\n"
-           "Open a file for output, creating it if it doesn't already\n"
-           "exist.  All writes to the port will go to the end of the file.\n"
-           "The \"append mode\" can be turned off while the port is in use\n"
-           "@pxref{Ports and File Descriptors, fcntl}\n"
-           "@end table\n"
-           "The following additional characters can be appended:\n"
-           "@table @samp\n"
-           "@item b\n"
-           "Open the underlying file in binary mode, if supported by the 
system.\n"
-           "Also, open the file using the binary-compatible character 
encoding\n"
-           "\"ISO-8859-1\", ignoring the port's encoding and the coding 
declaration\n"
-           "at the top of the input file, if any.\n"
-           "@item +\n"
-           "Open the port for both input and output.  E.g., @code{r+}: open\n"
-           "an existing file for both input and output.\n"
-           "@item 0\n"
-           "Create an \"unbuffered\" port.  In this case input and output\n"
-           "operations are passed directly to the underlying port\n"
-           "implementation without additional buffering.  This is likely to\n"
-           "slow down I/O operations.  The buffering mode can be changed\n"
-           "while a port is in use @pxref{Ports and File Descriptors,\n"
-           "setvbuf}\n"
-           "@item l\n"
-           "Add line-buffering to the port.  The port output buffer will be\n"
-           "automatically flushed whenever a newline character is written.\n"
-           "@end table\n"
-           "When the file is opened, this procedure will scan for a coding\n"
-           "address@hidden Encoding of Source Files}. If present\n"
-           "will use that encoding for interpreting the file.  Otherwise, 
the\n"
-           "port's encoding will be used.\n"
-           "\n"
-           "In theory we could create read/write ports which were buffered\n"
-           "in one direction only.  However this isn't included in the\n"
-           "current interfaces.  If a file cannot be opened with the access\n"
-           "requested, @code{open-file} throws an exception.")
-#define FUNC_NAME s_scm_open_file
+   The mode string must match the pattern: [rwa+]** which
+   is interpreted in the usual unix way.
+
+   Unless binary mode is requested, the character encoding of the new
+   port is determined as follows: First, if GUESS_ENCODING is true,
+   'file-encoding' is used to guess the encoding of the file.  If
+   GUESS_ENCODING is false or if 'file-encoding' fails, ENCODING is used
+   unless it is also false.  As a last resort, the default port encoding
+   is used.  It is an error to pass a non-false GUESS_ENCODING or
+   ENCODING if binary mode is requested.
+
+   Return the new port. */
+SCM
+scm_open_file_with_encoding (SCM filename, SCM mode,
+                             SCM guess_encoding, SCM encoding)
+#define FUNC_NAME "open-file"
 {
   SCM port;
-  int fdes, flags = 0, use_encoding = 1;
+  int fdes, flags = 0, binary = 0;
   unsigned int retries;
   char *file, *md, *ptr;
 
+  if (SCM_UNLIKELY (!(scm_is_false (encoding) || scm_is_string (encoding))))
+    scm_wrong_type_arg_msg (FUNC_NAME, 0, encoding,
+                            "encoding to be string or false");
+
   scm_dynwind_begin (0);
 
   file = scm_to_locale_string (filename);
@@ -434,7 +375,7 @@ SCM_DEFINE (scm_open_file, "open-file", 2, 0, 0,
          flags = (flags & ~(O_RDONLY | O_WRONLY)) | O_RDWR;
          break;
        case 'b':
-         use_encoding = 0;
+         binary = 1;
 #if defined (O_BINARY)
          flags |= O_BINARY;
 #endif
@@ -473,21 +414,44 @@ SCM_DEFINE (scm_open_file, "open-file", 2, 0, 0,
   port = scm_i_fdes_to_port (fdes, scm_i_mode_bits (mode),
                              fport_canonicalize_filename (filename));
 
-  if (use_encoding)
+  if (binary)
     {
-      /* If this file has a coding declaration, use that as the port
-        encoding.  */
-      if (SCM_INPUT_PORT_P (port))
-       {
-         char *enc = scm_i_scan_for_encoding (port);
-         if (enc != NULL)
-           scm_i_set_port_encoding_x (port, enc);
-       }
+      if (scm_is_true (encoding))
+        scm_misc_error (FUNC_NAME,
+                        "Encoding specified on a binary port",
+                        scm_list_1 (encoding));
+      if (scm_is_true (guess_encoding))
+        scm_misc_error (FUNC_NAME,
+                        "Request to guess encoding on a binary port",
+                        SCM_EOL);
+
+      /* Use the binary-friendly ISO-8859-1 encoding. */
+      scm_i_set_port_encoding_x (port, NULL);
     }
   else
-    /* If this is a binary file, use the binary-friendly ISO-8859-1
-       encoding.  */
-    scm_i_set_port_encoding_x (port, NULL);
+    {
+      char *enc = NULL;
+
+      if (scm_is_true (guess_encoding))
+        {
+          if (SCM_INPUT_PORT_P (port))
+            enc = scm_i_scan_for_encoding (port);
+          else
+            scm_misc_error (FUNC_NAME,
+                            "Request to guess encoding on an output-only port",
+                            SCM_EOL);
+        }
+
+      if (!enc && scm_is_true (encoding))
+        {
+          char *buf = scm_to_latin1_string (encoding);
+          enc = scm_gc_strdup (buf, "encoding");
+          free (buf);
+        }
+
+      if (enc)
+        scm_i_set_port_encoding_x (port, enc);
+    }
 
   scm_dynwind_end ();
 
@@ -495,49 +459,76 @@ SCM_DEFINE (scm_open_file, "open-file", 2, 0, 0,
 }
 #undef FUNC_NAME
 
-
-#ifdef __MINGW32__
-/*
- * Try getting the appropiate file flags for a given file descriptor
- * under Windows. This incorporates some fancy operations because Windows
- * differentiates between file, pipe and socket descriptors.
- */
-#ifndef O_ACCMODE
-# define O_ACCMODE 0x0003
-#endif
+SCM
+scm_open_file (SCM filename, SCM mode)
+{
+  return scm_open_file_with_encoding (filename, mode, SCM_BOOL_F, SCM_BOOL_F);
+}
+
+/* We can't define these using SCM_KEYWORD, because keywords have not
+   yet been initialized when scm_init_fports is called.  */
+static SCM k_guess_encoding = SCM_UNDEFINED;
+static SCM k_encoding       = SCM_UNDEFINED;
 
-static int getflags (int fdes)
+SCM_DEFINE (scm_i_open_file, "open-file", 2, 0, 1,
+           (SCM filename, SCM mode, SCM keyword_args),
+           "Open the file whose name is @var{filename}, and return a port\n"
+           "representing that file.  The attributes of the port are\n"
+           "determined by the @var{mode} string.  The way in which this is\n"
+           "interpreted is similar to C stdio.  The first character must be\n"
+           "one of the following:\n"
+           "@table @samp\n"
+           "@item r\n"
+           "Open an existing file for input.\n"
+           "@item w\n"
+           "Open a file for output, creating it if it doesn't already exist\n"
+           "or removing its contents if it does.\n"
+           "@item a\n"
+           "Open a file for output, creating it if it doesn't already\n"
+           "exist.  All writes to the port will go to the end of the file.\n"
+           "The \"append mode\" can be turned off while the port is in use\n"
+           "@pxref{Ports and File Descriptors, fcntl}\n"
+           "@end table\n"
+           "The following additional characters can be appended:\n"
+           "@table @samp\n"
+           "@item b\n"
+           "Open the underlying file in binary mode, if supported by the 
system.\n"
+           "Also, open the file using the binary-compatible character 
encoding\n"
+           "\"ISO-8859-1\", ignoring the default port encoding.\n"
+           "@item +\n"
+           "Open the port for both input and output.  E.g., @code{r+}: open\n"
+           "an existing file for both input and output.\n"
+           "@item 0\n"
+           "Create an \"unbuffered\" port.  In this case input and output\n"
+           "operations are passed directly to the underlying port\n"
+           "implementation without additional buffering.  This is likely to\n"
+           "slow down I/O operations.  The buffering mode can be changed\n"
+           "while a port is in use @pxref{Ports and File Descriptors,\n"
+           "setvbuf}\n"
+           "@item l\n"
+           "Add line-buffering to the port.  The port output buffer will be\n"
+           "automatically flushed whenever a newline character is written.\n"
+           "@end table\n"
+           "In theory we could create read/write ports which were buffered\n"
+           "in one direction only.  However this isn't included in the\n"
+           "current interfaces.  If a file cannot be opened with the access\n"
+           "requested, @code{open-file} throws an exception.")
+#define FUNC_NAME s_scm_i_open_file
 {
-  int flags = 0;
-  struct stat buf;
-  int error, optlen = sizeof (int);
-
-  /* Is this a socket ? */
-  if (getsockopt (fdes, SOL_SOCKET, SO_ERROR, (void *) &error, &optlen) >= 0)
-    flags = O_RDWR;
-  /* Maybe a regular file ? */
-  else if (fstat (fdes, &buf) < 0)
-    flags = -1;
-  else
-    {
-      /* Or an anonymous pipe handle ? */
-      if (buf.st_mode & _S_IFIFO)
-       flags = PeekNamedPipe ((HANDLE) _get_osfhandle (fdes), NULL, 0, 
-                              NULL, NULL, NULL) ? O_RDONLY : O_WRONLY;
-      /* stdin ? */
-      else if (fdes == fileno (stdin) && isatty (fdes))
-       flags = O_RDONLY;
-      /* stdout / stderr ? */
-      else if ((fdes == fileno (stdout) || fdes == fileno (stderr)) && 
-              isatty (fdes))
-       flags = O_WRONLY;
-      else
-       flags = buf.st_mode;
-    }
-  return flags;
+  SCM encoding = SCM_BOOL_F;
+  SCM guess_encoding = SCM_BOOL_F;
+
+  scm_c_bind_keyword_arguments (FUNC_NAME, keyword_args, 0,
+                                k_guess_encoding, &guess_encoding,
+                                k_encoding, &encoding,
+                                SCM_UNDEFINED);
+
+  return scm_open_file_with_encoding (filename, mode,
+                                      guess_encoding, encoding);
 }
-#endif /* __MINGW32__ */
+#undef FUNC_NAME
 
+
 /* Building Guile ports from a file descriptor.  */
 
 /* Build a Scheme port from an open file descriptor `fdes'.
@@ -551,14 +542,10 @@ scm_i_fdes_to_port (int fdes, long mode_bits, SCM name)
 {
   SCM port;
   scm_t_fport *fp;
-  int flags;
 
-  /* test that fdes is valid.  */
-#ifdef __MINGW32__
-  flags = getflags (fdes);
-#else
-  flags = fcntl (fdes, F_GETFL, 0);
-#endif
+  /* Test that fdes is valid.  */
+#ifdef F_GETFL
+  int flags = fcntl (fdes, F_GETFL, 0);
   if (flags == -1)
     SCM_SYSERROR;
   flags &= O_ACCMODE;
@@ -568,6 +555,13 @@ scm_i_fdes_to_port (int fdes, long mode_bits, SCM name)
     {
       SCM_MISC_ERROR ("requested file mode not available on fdes", SCM_EOL);
     }
+#else
+  /* If we don't have F_GETFL, as on mingw, at least we can test that
+     it is a valid file descriptor.  */
+  struct stat st;
+  if (fstat (fdes, &st) != 0)
+    SCM_SYSERROR;
+#endif
 
   fp = (scm_t_fport *) scm_gc_malloc_pointerless (sizeof (scm_t_fport),
                                                   "file port");
@@ -600,52 +594,12 @@ fport_input_waiting (SCM port)
 {
   int fdes = SCM_FSTREAM (port)->fdes;
 
-  /* `FD_SETSIZE', which is 1024 on GNU systems, effectively limits the
-     highest numerical value of file descriptors that can be monitored.
-     Thus, use poll(2) whenever that is possible.  */
-
-#ifdef HAVE_POLL
   struct pollfd pollfd = { fdes, POLLIN, 0 };
 
   if (poll (&pollfd, 1, 0) < 0)
     scm_syserror ("fport_input_waiting");
 
   return pollfd.revents & POLLIN ? 1 : 0;
-
-#elif defined(HAVE_SELECT)
-  struct timeval timeout;
-  SELECT_TYPE read_set;
-  SELECT_TYPE write_set;
-  SELECT_TYPE except_set;
-
-  FD_ZERO (&read_set);
-  FD_ZERO (&write_set);
-  FD_ZERO (&except_set);
-
-  FD_SET (fdes, &read_set);
-  
-  timeout.tv_sec = 0;
-  timeout.tv_usec = 0;
-
-  if (select (SELECT_SET_SIZE,
-             &read_set, &write_set, &except_set, &timeout)
-      < 0)
-    scm_syserror ("fport_input_waiting");
-  return FD_ISSET (fdes, &read_set) ? 1 : 0;
-
-#elif HAVE_IOCTL && defined (FIONREAD)
-  /* Note: cannot test just defined(FIONREAD) here, since mingw has FIONREAD
-     (for use with winsock ioctlsocket()) but not ioctl().  */
-  int fdes = SCM_FSTREAM (port)->fdes;
-  int remir;
-  ioctl(fdes, FIONREAD, &remir);
-  return remir;
-
-#else    
-  scm_misc_error ("fport_input_waiting",
-                 "Not fully implemented on this platform",
-                 SCM_EOL);
-#endif
 }
 
 
@@ -1022,6 +976,15 @@ scm_make_fptob ()
   return tc;
 }
 
+/* We can't initialize the keywords from 'scm_init_fports', because
+   keywords haven't yet been initialized at that point.  */
+void
+scm_init_fports_keywords ()
+{
+  k_guess_encoding = scm_from_latin1_keyword ("guess-encoding");
+  k_encoding       = scm_from_latin1_keyword ("encoding");
+}
+
 void
 scm_init_fports ()
 {
diff --git a/libguile/fports.h b/libguile/fports.h
index 4094f14..092b43e 100644
--- a/libguile/fports.h
+++ b/libguile/fports.h
@@ -54,6 +54,8 @@ SCM_API scm_t_bits scm_tc16_fport;
 SCM_API SCM scm_setbuf0 (SCM port);
 SCM_API SCM scm_setvbuf (SCM port, SCM mode, SCM size);
 SCM_API void scm_evict_ports (int fd);
+SCM_API SCM scm_open_file_with_encoding (SCM filename, SCM modes,
+                                         SCM guess_encoding, SCM encoding);
 SCM_API SCM scm_open_file (SCM filename, SCM modes);
 SCM_API SCM scm_fdes_to_port (int fdes, char *mode, SCM name);
 SCM_API SCM scm_file_port_p (SCM obj);
@@ -66,6 +68,7 @@ SCM_API SCM scm_set_port_revealed_x (SCM port, SCM rcount);
 SCM_API SCM scm_adjust_port_revealed_x (SCM port, SCM addend);
 
 
+SCM_INTERNAL void scm_init_fports_keywords (void);
 SCM_INTERNAL void scm_init_fports (void);
 
 /* internal functions */
diff --git a/libguile/gc.c b/libguile/gc.c
index d580a65..581bbc5 100644
--- a/libguile/gc.c
+++ b/libguile/gc.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2003, 2006, 2008, 
2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2003, 2006,
+ *   2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -281,7 +282,13 @@ SCM_DEFINE (scm_gc_stats, "gc-stats", 0, 0, 0,
 
   GC_get_heap_usage_safe (&heap_size, &free_bytes, &unmapped_bytes,
                           &bytes_since_gc, &total_bytes);
+#ifdef HAVE_GC_GET_GC_NO
+  /* This function was added in 7.2alpha2 (June 2009).  */
+  gc_times = GC_get_gc_no ();
+#else
+  /* This symbol is deprecated as of 7.3.  */
   gc_times = GC_gc_no;
+#endif
 
   answer =
     scm_list_n (scm_cons (sym_gc_time_taken, scm_from_long (gc_time_taken)),
@@ -582,7 +589,14 @@ scm_getenv_int (const char *var, int def)
 void
 scm_storage_prehistory ()
 {
+#ifdef HAVE_GC_SET_ALL_INTERIOR_POINTERS
+  /* This function was added in 7.2alpha2 (June 2009).  */
+  GC_set_all_interior_pointers (0);
+#else
+  /* This symbol is deprecated in 7.3.  */
   GC_all_interior_pointers = 0;
+#endif
+
   free_space_divisor = scm_getenv_int ("GC_FREE_SPACE_DIVISOR", 3);
   minimum_free_space_divisor = free_space_divisor;
   target_free_space_divisor = free_space_divisor;
diff --git a/libguile/gc.h b/libguile/gc.h
index b1df82d..0857781 100644
--- a/libguile/gc.h
+++ b/libguile/gc.h
@@ -4,7 +4,7 @@
 #define SCM_GC_H
 
 /* Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2006,
- *   2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+ *   2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -181,6 +181,7 @@ SCM_API char *scm_gc_strdup (const char *str, const char 
*what)
 SCM_API char *scm_gc_strndup (const char *str, size_t n, const char *what)
   SCM_MALLOC;
 
+#define scm_gc_typed_calloc(t) ((t *) scm_gc_calloc (sizeof (t), #t))
 
 #ifdef BUILDING_LIBGUILE
 #include "libguile/bdw-gc.h"
diff --git a/libguile/gen-scmconfig.c b/libguile/gen-scmconfig.c
index e1cc030..11020cf 100644
--- a/libguile/gen-scmconfig.c
+++ b/libguile/gen-scmconfig.c
@@ -1,3 +1,20 @@
+/* Copyright (C) 2003-2013 Free Software Foundation, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
 
 /**********************************************************************
 
@@ -268,7 +285,7 @@ main (int argc, char *argv[])
   pf ("typedef %s scm_t_uint64;\n", SCM_I_GSC_T_UINT64);
 
   pf ("\n");
-  pf ("/* scm_t_ptrdiff_t and size, always defined -- defined to long if\n"
+  pf ("/* scm_t_ptrdiff and size, always defined -- defined to long if\n"
       "   platform doesn't have ptrdiff_t. */\n");
   pf ("typedef %s scm_t_ptrdiff;\n", SCM_I_GSC_T_PTRDIFF);
   if (0 == strcmp ("long", SCM_I_GSC_T_PTRDIFF))
@@ -284,7 +301,7 @@ main (int argc, char *argv[])
 
   pf ("\n");
   pf ("/* same as POSIX \"struct timespec\" -- always defined */\n");
-#ifdef HAVE_STRUCT_TIMESPEC
+#ifdef HAVE_SYSTEM_STRUCT_TIMESPEC
   pf ("typedef struct timespec scm_t_timespec;\n");
 #else
   pf ("/* POSIX.4 structure for a time value.  This is like a `struct timeval'"
diff --git a/libguile/generalized-arrays.c b/libguile/generalized-arrays.c
index 3a0ce25..59925a0 100644
--- a/libguile/generalized-arrays.c
+++ b/libguile/generalized-arrays.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995,1996,1997,1998,2000,2001,2002,2003,2004, 2005, 2006, 
2009, 2010 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,2000,2001,2002,2003,2004, 2005, 2006, 
2009, 2010, 2013 Free Software Foundation, Inc.
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -33,6 +33,12 @@
 #include "libguile/generalized-arrays.h"
 
 
+SCM_INTERNAL SCM scm_i_array_ref (SCM v,
+                                  SCM idx0, SCM idx1, SCM idxN);
+SCM_INTERNAL SCM scm_i_array_set_x (SCM v, SCM obj,
+                                    SCM idx0, SCM idx1, SCM idxN);
+
+
 int
 scm_is_array (SCM obj)
 {
@@ -107,6 +113,35 @@ SCM_DEFINE (scm_array_rank, "array-rank", 1, 0, 0,
 #undef FUNC_NAME
 
 
+size_t
+scm_c_array_length (SCM array)
+{
+  scm_t_array_handle handle;
+  size_t res;
+
+  scm_array_get_handle (array, &handle);
+  if (scm_array_handle_rank (&handle) < 1)
+    {
+      scm_array_handle_release (&handle);
+      scm_wrong_type_arg_msg (NULL, 0, array, "array of nonzero rank");
+    }
+  res = handle.dims[0].ubnd - handle.dims[0].lbnd + 1;
+  scm_array_handle_release (&handle);
+
+  return res;
+}
+
+SCM_DEFINE (scm_array_length, "array-length", 1, 0, 0, 
+           (SCM array),
+           "Return the length of an array: its first dimension.\n"
+            "It is an error to ask for the length of an array of rank 0.")
+#define FUNC_NAME s_scm_array_length
+{
+  return scm_from_size_t (scm_c_array_length (array));
+}
+#undef FUNC_NAME
+
+
 SCM_DEFINE (scm_array_dimensions, "array-dimensions", 1, 0, 0, 
            (SCM ra),
            "@code{array-dimensions} is similar to @code{array-shape} but 
replaces\n"
@@ -195,11 +230,35 @@ SCM_DEFINE (scm_array_in_bounds_p, "array-in-bounds?", 1, 
0, 1,
 }
 #undef FUNC_NAME
 
-SCM_DEFINE (scm_array_ref, "array-ref", 1, 0, 1,
-           (SCM v, SCM args),
-           "Return the element at the @code{(index1, index2)} element in\n"
-           "array @var{v}.")
-#define FUNC_NAME s_scm_array_ref
+
+SCM
+scm_c_array_ref_1 (SCM array, ssize_t idx0)
+{
+  scm_t_array_handle handle;
+  SCM res;
+
+  scm_array_get_handle (array, &handle);
+  res = scm_array_handle_ref (&handle, scm_array_handle_pos_1 (&handle, idx0));
+  scm_array_handle_release (&handle);
+  return res;
+}
+
+
+SCM
+scm_c_array_ref_2 (SCM array, ssize_t idx0, ssize_t idx1)
+{
+  scm_t_array_handle handle;
+  SCM res;
+
+  scm_array_get_handle (array, &handle);
+  res = scm_array_handle_ref (&handle, scm_array_handle_pos_2 (&handle, idx0, 
idx1));
+  scm_array_handle_release (&handle);
+  return res;
+}
+
+
+SCM
+scm_array_ref (SCM v, SCM args)
 {
   scm_t_array_handle handle;
   SCM res;
@@ -209,15 +268,34 @@ SCM_DEFINE (scm_array_ref, "array-ref", 1, 0, 1,
   scm_array_handle_release (&handle);
   return res;
 }
-#undef FUNC_NAME
 
 
-SCM_DEFINE (scm_array_set_x, "array-set!", 2, 0, 1, 
-           (SCM v, SCM obj, SCM args),
-           "Set the element at the @code{(index1, index2)} element in array\n"
-           "@var{v} to @var{obj}.  The value returned by @code{array-set!}\n"
-           "is unspecified.")
-#define FUNC_NAME s_scm_array_set_x           
+void
+scm_c_array_set_1_x (SCM array, SCM obj, ssize_t idx0)
+{
+  scm_t_array_handle handle;
+
+  scm_array_get_handle (array, &handle);
+  scm_array_handle_set (&handle, scm_array_handle_pos_1 (&handle, idx0),
+                        obj);
+  scm_array_handle_release (&handle);
+}
+
+
+void
+scm_c_array_set_2_x (SCM array, SCM obj, ssize_t idx0, ssize_t idx1)
+{
+  scm_t_array_handle handle;
+
+  scm_array_get_handle (array, &handle);
+  scm_array_handle_set (&handle, scm_array_handle_pos_2 (&handle, idx0, idx1),
+                        obj);
+  scm_array_handle_release (&handle);
+}
+
+
+SCM
+scm_array_set_x (SCM v, SCM obj, SCM args)
 {
   scm_t_array_handle handle;
 
@@ -226,8 +304,47 @@ SCM_DEFINE (scm_array_set_x, "array-set!", 2, 0, 1,
   scm_array_handle_release (&handle);
   return SCM_UNSPECIFIED;
 }
+
+
+SCM_DEFINE (scm_i_array_ref, "array-ref", 1, 2, 1,
+            (SCM v, SCM idx0, SCM idx1, SCM idxN),
+           "Return the element at the @code{(idx0, idx1, idxN...)}\n"
+            "position in array @var{v}.")
+#define FUNC_NAME s_scm_i_array_ref
+{
+  if (SCM_UNBNDP (idx0))
+    return scm_array_ref (v, SCM_EOL);
+  else if (SCM_UNBNDP (idx1))
+    return scm_c_array_ref_1 (v, scm_to_ssize_t (idx0));
+  else if (scm_is_null (idxN))
+    return scm_c_array_ref_2 (v, scm_to_ssize_t (idx0), scm_to_ssize_t (idx1));
+  else
+    return scm_array_ref (v, scm_cons (idx0, scm_cons (idx1, idxN)));
+}
 #undef FUNC_NAME
 
+
+SCM_DEFINE (scm_i_array_set_x, "array-set!", 2, 2, 1,
+            (SCM v, SCM obj, SCM idx0, SCM idx1, SCM idxN),
+           "Set the element at the @code{(idx0, idx1, idxN...)} position\n"
+           "in the array @var{v} to @var{obj}.  The value returned by\n"
+            "@code{array-set!} is unspecified.")
+#define FUNC_NAME s_scm_i_array_set_x
+{
+  if (SCM_UNBNDP (idx0))
+    scm_array_set_x (v, obj, SCM_EOL);
+  else if (SCM_UNBNDP (idx1))
+    scm_c_array_set_1_x (v, obj, scm_to_ssize_t (idx0));
+  else if (scm_is_null (idxN))
+    scm_c_array_set_2_x (v, obj, scm_to_ssize_t (idx0), scm_to_ssize_t (idx1));
+  else
+    scm_array_set_x (v, obj, scm_cons (idx0, scm_cons (idx1, idxN)));
+
+  return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+
+
 static SCM 
 array_to_list (scm_t_array_handle *h, size_t dim, unsigned long pos)
 {
diff --git a/libguile/generalized-arrays.h b/libguile/generalized-arrays.h
index 1f9b6ad..d9fcea6 100644
--- a/libguile/generalized-arrays.h
+++ b/libguile/generalized-arrays.h
@@ -3,7 +3,7 @@
 #ifndef SCM_GENERALIZED_ARRAYS_H
 #define SCM_GENERALIZED_ARRAYS_H
 
-/* Copyright (C) 1995,1996,1997,1999,2000,2001, 2004, 2006, 2008, 2009 Free 
Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1999,2000,2001, 2004, 2006, 2008, 2009, 2013 
Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -44,10 +44,19 @@ SCM_API SCM scm_typed_array_p (SCM v, SCM type);
 SCM_API size_t scm_c_array_rank (SCM ra);
 SCM_API SCM scm_array_rank (SCM ra);
 
+SCM_API size_t scm_c_array_length (SCM ra);
+SCM_API SCM scm_array_length (SCM ra);
+
 SCM_API SCM scm_array_dimensions (SCM ra);
 SCM_API SCM scm_array_type (SCM ra);
 SCM_API SCM scm_array_in_bounds_p (SCM v, SCM args);
 
+SCM_API SCM scm_c_array_ref_1 (SCM v, ssize_t idx0);
+SCM_API SCM scm_c_array_ref_2 (SCM v, ssize_t idx0, ssize_t idx1);
+
+SCM_API void scm_c_array_set_1_x (SCM v, SCM obj, ssize_t idx0);
+SCM_API void scm_c_array_set_2_x (SCM v, SCM obj, ssize_t idx0, ssize_t idx1);
+
 SCM_API SCM scm_array_ref (SCM v, SCM args);
 SCM_API SCM scm_array_set_x (SCM v, SCM obj, SCM args);
 SCM_API SCM scm_array_to_list (SCM v);
diff --git a/libguile/generalized-vectors.c b/libguile/generalized-vectors.c
index 4da0e88..5e3e552 100644
--- a/libguile/generalized-vectors.c
+++ b/libguile/generalized-vectors.c
@@ -1,5 +1,5 @@
 /* Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004,
- *   2005, 2006, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+ *   2005, 2006, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -83,16 +83,6 @@ scm_is_generalized_vector (SCM obj)
   return ret;
 }
 
-SCM_DEFINE (scm_generalized_vector_p, "generalized-vector?", 1, 0, 0,
-           (SCM obj),
-           "Return @code{#t} if @var{obj} is a vector, string,\n"
-           "bitvector, or uniform numeric vector.")
-#define FUNC_NAME s_scm_generalized_vector_p
-{
-  return scm_from_bool (scm_is_generalized_vector (obj));
-}
-#undef FUNC_NAME
-
 #define SCM_VALIDATE_VECTOR_WITH_HANDLE(pos, val, handle)   \
   scm_generalized_vector_get_handle (val, handle)
    
@@ -119,15 +109,6 @@ scm_c_generalized_vector_length (SCM v)
   return ret;
 }
 
-SCM_DEFINE (scm_generalized_vector_length, "generalized-vector-length", 1, 0, 
0,
-           (SCM v),
-           "Return the length of the generalized vector @var{v}.")
-#define FUNC_NAME s_scm_generalized_vector_length
-{
-  return scm_from_size_t (scm_c_generalized_vector_length (v));
-}
-#undef FUNC_NAME
-
 SCM
 scm_c_generalized_vector_ref (SCM v, size_t idx)
 {
@@ -141,16 +122,6 @@ scm_c_generalized_vector_ref (SCM v, size_t idx)
   return ret;
 }
 
-SCM_DEFINE (scm_generalized_vector_ref, "generalized-vector-ref", 2, 0, 0,
-           (SCM v, SCM idx),
-           "Return the element at index @var{idx} of the\n"
-           "generalized vector @var{v}.")
-#define FUNC_NAME s_scm_generalized_vector_ref
-{
-  return scm_c_generalized_vector_ref (v, scm_to_size_t (idx));
-}
-#undef FUNC_NAME
-
 void
 scm_c_generalized_vector_set_x (SCM v, size_t idx, SCM val)
 {
@@ -162,43 +133,6 @@ scm_c_generalized_vector_set_x (SCM v, size_t idx, SCM val)
   scm_array_handle_release (&h);
 }
 
-SCM_DEFINE (scm_generalized_vector_set_x, "generalized-vector-set!", 3, 0, 0,
-           (SCM v, SCM idx, SCM val),
-           "Set the element at index @var{idx} of the\n"
-           "generalized vector @var{v} to @var{val}.")
-#define FUNC_NAME s_scm_generalized_vector_set_x
-{
-  scm_c_generalized_vector_set_x (v, scm_to_size_t (idx), val);
-  return SCM_UNSPECIFIED;
-}
-#undef FUNC_NAME
-
-SCM_DEFINE (scm_generalized_vector_to_list, "generalized-vector->list", 1, 0, 
0,
-           (SCM v),
-           "Return a new list whose elements are the elements of the\n"
-           "generalized vector @var{v}.")
-#define FUNC_NAME s_scm_generalized_vector_to_list
-{
-  /* FIXME: This duplicates `array_to_list'.  */
-  SCM ret = SCM_EOL;
-  long inc;
-  ssize_t pos, i;
-  scm_t_array_handle h;
-
-  scm_generalized_vector_get_handle (v, &h);
-
-  i = h.dims[0].ubnd - h.dims[0].lbnd + 1;
-  inc = h.dims[0].inc;
-  pos = (i - 1) * inc;
-
-  for (; i > 0; i--, pos -= inc)
-    ret = scm_cons (h.impl->vref (&h, h.base + pos), ret);
-
-  scm_array_handle_release (&h);
-  return ret;
-}
-#undef FUNC_NAME
-
 void
 scm_init_generalized_vectors ()
 {
diff --git a/libguile/generalized-vectors.h b/libguile/generalized-vectors.h
index 71b58d2..e2acb98 100644
--- a/libguile/generalized-vectors.h
+++ b/libguile/generalized-vectors.h
@@ -3,7 +3,7 @@
 #ifndef SCM_GENERALIZED_VECTORS_H
 #define SCM_GENERALIZED_VECTORS_H
 
-/* Copyright (C) 1995,1996,1997,1999,2000,2001, 2004, 2006, 2008, 2009 Free 
Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1999,2000,2001, 2004, 2006, 2008, 2009, 2013 
Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -30,12 +30,6 @@
 
 /* Generalized vectors */
 
-SCM_API SCM scm_generalized_vector_p (SCM v);
-SCM_API SCM scm_generalized_vector_length (SCM v);
-SCM_API SCM scm_generalized_vector_ref (SCM v, SCM idx);
-SCM_API SCM scm_generalized_vector_set_x (SCM v, SCM idx, SCM val);
-SCM_API SCM scm_generalized_vector_to_list (SCM v);
-
 SCM_API int scm_is_generalized_vector (SCM obj);
 SCM_API size_t scm_c_generalized_vector_length (SCM v);
 SCM_API SCM scm_c_generalized_vector_ref (SCM v, size_t idx);
diff --git a/libguile/guardians.c b/libguile/guardians.c
index 8a0d296..49d7cba 100644
--- a/libguile/guardians.c
+++ b/libguile/guardians.c
@@ -1,5 +1,5 @@
 /* Copyright (C) 1998,1999,2000,2001, 2006, 2008, 2009, 2011,
- *   2012 Free Software Foundation, Inc.
+ *   2012, 2013 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -355,7 +355,13 @@ void
 scm_init_guardians ()
 {
   /* We use unordered finalization `a la Java.  */
+#ifdef HAVE_GC_SET_JAVA_FINALIZATION
+  /* This function was added in 7.2alpha2 (June 2009).  */
+  GC_set_java_finalization (1);
+#else
+  /* This symbol is deprecated as of 7.3.  */
   GC_java_finalization = 1;
+#endif
 
   tc16_guardian = scm_make_smob_type ("guardian", 0);
 
diff --git a/libguile/guile.c b/libguile/guile.c
index 133afc4..03b603e 100644
--- a/libguile/guile.c
+++ b/libguile/guile.c
@@ -1,5 +1,5 @@
 /* Copyright (C) 1996, 1997, 2000, 2001, 2006, 2008,
- *   2011 Free Software Foundation, Inc.
+ *   2011, 2013 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -66,15 +66,41 @@ inner_main (void *closure SCM_UNUSED, int argc, char **argv)
 #endif /* __MINGW32__ */
 }
 
+static int
+get_integer_from_environment (const char *var, int def)
+{
+  char *end = 0;
+  char *val = getenv (var);
+  long res = def;
+  if (!val)
+    return def;
+  res = strtol (val, &end, 10);
+  if (end == val)
+    {
+      fprintf (stderr, "guile: warning: invalid %s: %s\n", var, val);
+      return def;
+    }
+  return res;
+}
+
+static int
+should_install_locale (void)
+{
+  /* If the GUILE_INSTALL_LOCALE environment variable is unset,
+     or set to a nonzero value, we should install the locale via
+     setlocale().  */
+  return get_integer_from_environment ("GUILE_INSTALL_LOCALE", 1);
+}
+
 int
 main (int argc, char **argv)
 {
-  /* Install the locale right at the beginning so that string conversion
-     for command-line arguments, along with possible error messages, use
-     the right locale.  See
+  /* If we should install a locale, do it right at the beginning so that
+     string conversion for command-line arguments, along with possible
+     error messages, use the right locale.  See
      <https://lists.gnu.org/archive/html/guile-devel/2011-11/msg00041.html>
      for the rationale.  */
-  if (setlocale (LC_ALL, "") == NULL)
+  if (should_install_locale () && setlocale (LC_ALL, "") == NULL)
     fprintf (stderr, "guile: warning: failed to install locale\n");
 
   scm_install_gmp_memory_functions = 1;
diff --git a/libguile/hashtab.c b/libguile/hashtab.c
index fc7fa42..fff48b8 100644
--- a/libguile/hashtab.c
+++ b/libguile/hashtab.c
@@ -205,6 +205,7 @@ SCM_DEFINE (scm_hash_table_p, "hash-table?", 1, 0, 0,
 }
 #undef FUNC_NAME
 
+
 
 /* Accessing hash table entries.  */
 
@@ -966,6 +967,33 @@ SCM_DEFINE (scm_hash_map_to_list, "hash-map->list", 2, 0, 
0,
 }
 #undef FUNC_NAME
 
+static SCM
+count_proc (void *pred, SCM key, SCM data, SCM value)
+{
+  if (scm_is_false (scm_call_2 (SCM_PACK (pred), key, data)))
+    return value;
+  else
+    return scm_oneplus(value);
+}
+
+SCM_DEFINE (scm_hash_count, "hash-count", 2, 0, 0,
+            (SCM pred, SCM table),
+            "Return the number of elements in the given hash TABLE that\n"
+            "cause `(PRED KEY VALUE)' to return true.  To quickly determine\n"
+            "the total number of elements, use `(const #t)' for PRED.")
+#define FUNC_NAME s_scm_hash_count
+{
+  SCM init;
+
+  SCM_VALIDATE_PROC (1, pred);
+  SCM_VALIDATE_HASHTABLE (2, table);
+
+  init = scm_from_int (0);
+  return scm_internal_hash_fold ((scm_t_hash_fold_fn) count_proc,
+                                (void *) SCM_UNPACK (pred), init, table);
+}
+#undef FUNC_NAME
+
 
 
 SCM
diff --git a/libguile/hashtab.h b/libguile/hashtab.h
index 8eb685a..82ed22e 100644
--- a/libguile/hashtab.h
+++ b/libguile/hashtab.h
@@ -134,6 +134,7 @@ SCM_API SCM scm_hash_fold (SCM proc, SCM init, SCM hash);
 SCM_API SCM scm_hash_for_each (SCM proc, SCM hash);
 SCM_API SCM scm_hash_for_each_handle (SCM proc, SCM hash);
 SCM_API SCM scm_hash_map_to_list (SCM proc, SCM hash);
+SCM_API SCM scm_hash_count (SCM hash, SCM pred);
 SCM_INTERNAL void scm_i_hashtable_print (SCM exp, SCM port, scm_print_state 
*pstate);
 SCM_INTERNAL void scm_init_hashtab (void);
 
diff --git a/libguile/i18n.c b/libguile/i18n.c
index 817c661..dc6d07d 100644
--- a/libguile/i18n.c
+++ b/libguile/i18n.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software 
Foundation, Inc.
+/* Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software 
Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -685,6 +685,8 @@ SCM_DEFINE (scm_make_locale, "make-locale", 2, 1, 0,
       }
   }
 
+  /* silence gcc's unused variable warning */
+  (void) c_base_locale;
 #endif
 
   return locale;
diff --git a/libguile/init.c b/libguile/init.c
index 684f6eb..6787483 100644
--- a/libguile/init.c
+++ b/libguile/init.c
@@ -1,5 +1,5 @@
 /* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
- *   2004, 2006, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+ *   2004, 2006, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -75,7 +75,6 @@
 #include "libguile/gettext.h"
 #include "libguile/i18n.h"
 #include "libguile/instructions.h"
-#include "libguile/iselect.h"
 #include "libguile/ioext.h"
 #include "libguile/keywords.h"
 #include "libguile/list.h"
@@ -443,6 +442,7 @@ scm_i_init_guile (void *base)
   scm_init_gettext ();
   scm_init_ioext ();
   scm_init_keywords ();    /* Requires smob_prehistory */
+  scm_init_fports_keywords ();
   scm_init_list ();
   scm_init_random ();      /* Requires smob_prehistory */
   scm_init_macros ();      /* Requires smob_prehistory and random */
diff --git a/libguile/inline.c b/libguile/inline.c
index e005b26..6e7688c 100644
--- a/libguile/inline.c
+++ b/libguile/inline.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2006, 2008, 2011, 2012 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2006, 2008, 2011, 2012, 2013 Free Software Foundation, 
Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -23,6 +23,7 @@
 #define SCM_IMPLEMENT_INLINES 1
 #define SCM_INLINE_C_IMPLEMENTING_INLINES 1
 #include "libguile/inline.h"
+#include "libguile/array-handle.h"
 #include "libguile/gc.h"
 #include "libguile/smob.h"
 #include "libguile/pairs.h"
diff --git a/libguile/inline.h b/libguile/inline.h
index 89bbf9d..3c9b09b 100644
--- a/libguile/inline.h
+++ b/libguile/inline.h
@@ -4,7 +4,7 @@
 #define SCM_INLINE_H
 
 /* Copyright (C) 2001, 2002, 2003, 2004, 2006, 2008, 2009, 2010,
- *   2011, 2012 Free Software Foundation, Inc.
+ *   2011, 2012, 2013 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -37,9 +37,6 @@
 #include "libguile/error.h"
 
 
-SCM_INLINE SCM scm_array_handle_ref (scm_t_array_handle *h, ssize_t pos);
-SCM_INLINE void scm_array_handle_set (scm_t_array_handle *h, ssize_t pos, SCM 
val);
-
 SCM_INLINE int scm_is_string (SCM x);
 
 SCM_INLINE SCM scm_cell (scm_t_bits car, scm_t_bits cdr);
@@ -50,26 +47,6 @@ SCM_INLINE SCM scm_words (scm_t_bits car, scm_t_uint32 
n_words);
 #if SCM_CAN_INLINE || defined SCM_INLINE_C_IMPLEMENTING_INLINES
 /* Either inlining, or being included from inline.c.  */
 
-SCM_INLINE_IMPLEMENTATION SCM
-scm_array_handle_ref (scm_t_array_handle *h, ssize_t p)
-{
-  if (SCM_UNLIKELY (p < 0 && ((size_t)-p) > h->base))
-    /* catch overflow */
-    scm_out_of_range (NULL, scm_from_ssize_t (p));
-  /* perhaps should catch overflow here too */
-  return h->impl->vref (h, h->base + p);
-}
-
-SCM_INLINE_IMPLEMENTATION void
-scm_array_handle_set (scm_t_array_handle *h, ssize_t p, SCM v)
-{
-  if (SCM_UNLIKELY (p < 0 && ((size_t)-p) > h->base))
-    /* catch overflow */
-    scm_out_of_range (NULL, scm_from_ssize_t (p));
-  /* perhaps should catch overflow here too */
-  h->impl->vset (h, h->base + p, v);
-}
-
 SCM_INLINE_IMPLEMENTATION int
 scm_is_string (SCM x)
 {
diff --git a/libguile/instructions.c b/libguile/instructions.c
index 11004fc..08f7cd6 100644
--- a/libguile/instructions.c
+++ b/libguile/instructions.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, 
Inc.
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -64,8 +64,8 @@ struct scm_instruction {
     M(X8_U12_U12)                               \
     M(X8_R24)                                   \
     M(X8_L24)                                   \
-    M(U1_X7_L24)                                \
-    M(U1_U7_L24)
+    M(B1_X7_L24)                                \
+    M(B1_U7_L24)
 
 #define TYPE_WIDTH 5
 
diff --git a/libguile/iselect.h b/libguile/iselect.h
index 760d959..1c7b12d 100644
--- a/libguile/iselect.h
+++ b/libguile/iselect.h
@@ -3,7 +3,8 @@
 #ifndef SCM_ISELECT_H
 #define SCM_ISELECT_H
 
-/* Copyright (C) 1997,1998,2000,2001, 2002, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 1997,1998,2000,2001, 2002, 2006,
+ *   2013 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -29,35 +30,18 @@
 #include <sys/types.h>
 
 #if SCM_HAVE_SYS_SELECT_H
-# include <sys/select.h>
-#endif
 
-#if SCM_HAVE_WINSOCK2_H
-# include <winsock2.h>
-#endif
+#include <sys/select.h>
 
-#ifdef FD_SET
+SCM_API int scm_std_select (int fds,
+                           fd_set *rfds,
+                           fd_set *wfds,
+                           fd_set *efds,
+                           struct timeval *timeout);
 
 #define SELECT_TYPE fd_set
-#define SELECT_SET_SIZE FD_SETSIZE
-
-#else /* no FD_SET */
-
-/* Define the macros to access a single-int bitmap of descriptors.  */
-#define SELECT_SET_SIZE 32
-#define SELECT_TYPE int
-#define FD_SET(n, p) (*(p) |= (1 << (n)))
-#define FD_CLR(n, p) (*(p) &= ~(1 << (n)))
-#define FD_ISSET(n, p) (*(p) & (1 << (n)))
-#define FD_ZERO(p) (*(p) = 0)
 
-#endif /* no FD_SET */
-
-SCM_API int scm_std_select (int fds,
-                           SELECT_TYPE *rfds,
-                           SELECT_TYPE *wfds,
-                           SELECT_TYPE *efds,
-                           struct timeval *timeout);
+#endif /* SCM_HAVE_SYS_SELECT_H */
 
 #endif  /* SCM_ISELECT_H */
 
diff --git a/libguile/keywords.c b/libguile/keywords.c
index e4a79ac..96c0b01 100644
--- a/libguile/keywords.c
+++ b/libguile/keywords.c
@@ -23,6 +23,7 @@
 #endif
 
 #include <string.h>
+#include <stdarg.h>
 
 #include "libguile/_scm.h"
 #include "libguile/async.h"
@@ -124,6 +125,72 @@ scm_from_utf8_keyword (const char *name)
   return scm_symbol_to_keyword (scm_from_utf8_symbol (name));
 }
 
+SCM_SYMBOL (scm_keyword_argument_error, "keyword-argument-error");
+
+void
+scm_c_bind_keyword_arguments (const char *subr, SCM rest,
+                              scm_t_keyword_arguments_flags flags, ...)
+{
+  va_list va;
+
+  if (SCM_UNLIKELY (!(flags & SCM_ALLOW_NON_KEYWORD_ARGUMENTS)
+                    && scm_ilength (rest) % 2 != 0))
+    scm_error (scm_keyword_argument_error,
+               subr, "Odd length of keyword argument list",
+               SCM_EOL, SCM_BOOL_F);
+
+  while (scm_is_pair (rest))
+    {
+      SCM kw_or_arg = SCM_CAR (rest);
+      SCM tail = SCM_CDR (rest);
+
+      if (scm_is_keyword (kw_or_arg) && scm_is_pair (tail))
+        {
+          SCM kw;
+          SCM *arg_p;
+
+          va_start (va, flags);
+          for (;;)
+            {
+              kw = va_arg (va, SCM);
+              if (SCM_UNBNDP (kw))
+                {
+                  /* KW_OR_ARG is not in the list of expected keywords.  */
+                  if (!(flags & SCM_ALLOW_OTHER_KEYS))
+                    scm_error (scm_keyword_argument_error,
+                               subr, "Unrecognized keyword",
+                               SCM_EOL, SCM_BOOL_F);
+                  break;
+                }
+              arg_p = va_arg (va, SCM *);
+              if (scm_is_eq (kw_or_arg, kw))
+                {
+                  /* We found the matching keyword.  Store the
+                     associated value and break out of the loop.  */
+                  *arg_p = SCM_CAR (tail);
+                  break;
+                }
+            }
+          va_end (va);
+
+          /* Advance REST.  */
+          rest = SCM_CDR (tail);
+        }
+      else
+        {
+          /* The next argument is not a keyword, or is a singleton
+             keyword at the end of REST.  */
+          if (!(flags & SCM_ALLOW_NON_KEYWORD_ARGUMENTS))
+            scm_error (scm_keyword_argument_error,
+                       subr, "Invalid keyword",
+                       SCM_EOL, SCM_BOOL_F);
+
+           /* Advance REST.  */
+           rest = tail;
+        }
+    }
+}
+
 /* njrev: critical sections reviewed so far up to here */
 void
 scm_init_keywords ()
diff --git a/libguile/keywords.h b/libguile/keywords.h
index c9e6af1..3cdb0ec 100644
--- a/libguile/keywords.h
+++ b/libguile/keywords.h
@@ -41,6 +41,18 @@ SCM_API SCM scm_from_locale_keywordn (const char *name, 
size_t len);
 SCM_API SCM scm_from_latin1_keyword (const char *name);
 SCM_API SCM scm_from_utf8_keyword (const char *name);
 
+enum scm_keyword_arguments_flags
+{
+  SCM_ALLOW_OTHER_KEYS            = (1U << 0),
+  SCM_ALLOW_NON_KEYWORD_ARGUMENTS = (1U << 1)
+};
+
+typedef enum scm_keyword_arguments_flags scm_t_keyword_arguments_flags;
+
+SCM_API void
+scm_c_bind_keyword_arguments (const char *subr, SCM rest,
+                              scm_t_keyword_arguments_flags flags, ...);
+
 SCM_INTERNAL void scm_init_keywords (void);
 
 #endif  /* SCM_KEYWORDS_H */
diff --git a/libguile/list.c b/libguile/list.c
index 6276403..1f44ad0 100644
--- a/libguile/list.c
+++ b/libguile/list.c
@@ -377,8 +377,6 @@ SCM_DEFINE (scm_reverse_x, "reverse!", 1, 1, 0,
   SCM_VALIDATE_LIST (1, lst);
   if (SCM_UNBNDP (new_tail))
     new_tail = SCM_EOL;
-  else
-    SCM_VALIDATE_LIST (2, new_tail);
 
   while (!SCM_NULL_OR_NIL_P (lst))
     {
diff --git a/libguile/load.c b/libguile/load.c
index 081c364..ebf79a9 100644
--- a/libguile/load.c
+++ b/libguile/load.c
@@ -198,6 +198,19 @@ SCM_DEFINE (scm_sys_global_site_dir, "%global-site-dir", 
0,0,0,
 #undef FUNC_NAME
 #endif /* SCM_GLOBAL_SITE_DIR */
 
+#ifdef SCM_SITE_CCACHE_DIR
+SCM_DEFINE (scm_sys_site_ccache_dir, "%site-ccache-dir", 0,0,0,
+            (),
+           "Return the directory where users should install compiled\n"
+            "@code{.go} files for use with this version of Guile.\n\n"
+           "E.g., may return \"/usr/lib/guile/" SCM_EFFECTIVE_VERSION 
"/site-ccache\".")
+#define FUNC_NAME s_scm_sys_site_ccache_dir
+{
+  return scm_from_locale_string (SCM_SITE_CCACHE_DIR);
+}
+#undef FUNC_NAME
+#endif /* SCM_SITE_CCACHE_DIR */
+
 
 
 /* Initializing the load path, and searching it.  */
@@ -447,6 +460,60 @@ scm_c_string_has_an_ext (char *str, size_t len, SCM 
extensions)
   return 0;
 }
 
+#ifdef __MINGW32__
+#define FILE_NAME_SEPARATOR_STRING "\\"
+#else
+#define FILE_NAME_SEPARATOR_STRING "/"
+#endif
+
+static int
+is_file_name_separator (SCM c)
+{
+  if (scm_is_eq (c, SCM_MAKE_CHAR ('/')))
+    return 1;
+#ifdef __MINGW32__
+  if (scm_is_eq (c, SCM_MAKE_CHAR ('\\')))
+    return 1;
+#endif
+  return 0;
+}
+
+static int
+is_drive_letter (SCM c)
+{
+#ifdef __MINGW32__
+  if (SCM_CHAR (c) >= 'a' && SCM_CHAR (c) <= 'z')
+    return 1;
+  else if (SCM_CHAR (c) >= 'A' && SCM_CHAR (c) <= 'Z')
+    return 1;
+#endif
+  return 0;
+}
+
+static int
+is_absolute_file_name (SCM filename)
+{
+  size_t filename_len = scm_c_string_length (filename);
+
+  if (filename_len >= 1
+      && is_file_name_separator (scm_c_string_ref (filename, 0))
+#ifdef __MINGW32__
+      /* On Windows, one initial separator indicates a drive-relative
+         path.  Two separators indicate a Universal Naming Convention
+         (UNC) path.  UNC paths are always absolute.  */
+      && filename_len >= 2
+      && is_file_name_separator (scm_c_string_ref (filename, 1))
+#endif
+      )
+    return 1;
+  if (filename_len >= 3
+      && is_drive_letter (scm_c_string_ref (filename, 0))
+      && scm_is_eq (scm_c_string_ref (filename, 1), SCM_MAKE_CHAR (':'))
+      && is_file_name_separator (scm_c_string_ref (filename, 2)))
+    return 1;
+  return 0;
+}
+
 /* Search PATH for a directory containing a file named FILENAME.
    The file must be readable, and not a directory.
    If we find one, return its full pathname; otherwise, return #f.
@@ -477,16 +544,7 @@ search_path (SCM path, SCM filename, SCM extensions, SCM 
require_exts,
   scm_dynwind_free (filename_chars);
 
   /* If FILENAME is absolute and is still valid, return it unchanged.  */
-#ifdef __MINGW32__
-  if (((filename_len >= 1) && 
-       (filename_chars[0] == '/' || filename_chars[0] == '\\')) ||
-      ((filename_len >= 3) && filename_chars[1] == ':' &&
-       ((filename_chars[0] >= 'a' && filename_chars[0] <= 'z') ||
-       (filename_chars[0] >= 'A' && filename_chars[0] <= 'Z')) &&
-       (filename_chars[2] == '/' || filename_chars[2] == '\\')))
-#else
-  if (filename_len >= 1 && filename_chars[0] == '/')
-#endif
+  if (is_absolute_file_name (filename))
     {
       if ((scm_is_false (require_exts) ||
            scm_c_string_has_an_ext (filename_chars, filename_len,
@@ -520,11 +578,7 @@ search_path (SCM path, SCM filename, SCM extensions, SCM 
require_exts,
            extensions = SCM_EOL;
            break;
          }
-#ifdef __MINGW32__
-       else if (*endp == '/' || *endp == '\\')
-#else
-       else if (*endp == '/')
-#endif
+       else if (is_file_name_separator (SCM_MAKE_CHAR (*endp)))
          /* This filename has no extension, so keep the current list
              of extensions.  */
          break;
@@ -553,12 +607,9 @@ search_path (SCM path, SCM filename, SCM extensions, SCM 
require_exts,
        
       /* Concatenate the path name and the filename. */
       
-#ifdef __MINGW32__
-      if ((buf.ptr > buf.buf) && (buf.ptr[-1] != '/') && (buf.ptr[-1] != '\\'))
-#else
-      if ((buf.ptr > buf.buf) && (buf.ptr[-1] != '/'))
-#endif
-       stringbuf_cat (&buf, "/");
+      if (buf.ptr > buf.buf
+          && !is_file_name_separator (SCM_MAKE_CHAR (buf.ptr[-1])))
+       stringbuf_cat (&buf, FILE_NAME_SEPARATOR_STRING);
 
       stringbuf_cat (&buf, filename_chars);
       sans_ext_len = buf.ptr - buf.buf;
@@ -823,24 +874,36 @@ scm_try_auto_compile (SCM source)
                       NULL, NULL);
 }
 
-/* See also (system base compile):compiled-file-name. */
+/* The auto-compilation code will residualize a .go file in the cache
+   dir: by default, $HOME/.cache/guile/2.0/ccache/PATH.go.  This
+   function determines the PATH to use as a key into the compilation
+   cache.  See also (system base compile):compiled-file-name. */
 static SCM
 canonical_suffix (SCM fname)
 {
   SCM canon;
-  size_t len;
 
+  /* CANON should be absolute.  */
   canon = scm_canonicalize_path (fname);
-  len = scm_c_string_length (canon);
   
-  if (len > 1 && scm_is_eq (scm_c_string_ref (canon, 0), SCM_MAKE_CHAR ('/')))
-    return canon;
-  else if (len > 2 && scm_is_eq (scm_c_string_ref (canon, 1), SCM_MAKE_CHAR 
(':')))
-    return scm_string_append (scm_list_3 (scm_from_latin1_string ("/"),
-                                          scm_c_substring (canon, 0, 1),
-                                          scm_c_substring (canon, 2, len)));
-  else
-    return canon;
+#ifdef __MINGW32__
+  {
+    size_t len = scm_c_string_length (canon);
+
+    /* On Windows, an absolute file name that doesn't start with a
+       separator starts with a drive component.  Transform the drive
+       component to a file name element: c:\foo -> \c\foo. */
+    if (len >= 2
+        && is_absolute_file_name (canon)
+        && !is_file_name_separator (scm_c_string_ref (canon, 0)))
+      return scm_string_append
+        (scm_list_3 (scm_from_latin1_string (FILE_NAME_SEPARATOR_STRING),
+                     scm_c_substring (canon, 0, 1),
+                     scm_c_substring (canon, 2, len)));
+  }
+#endif
+
+  return canon;
 }
 
 SCM_DEFINE (scm_primitive_load_path, "primitive-load-path", 0, 0, 1,
diff --git a/libguile/load.h b/libguile/load.h
index 698bbaf..ab75ea3 100644
--- a/libguile/load.h
+++ b/libguile/load.h
@@ -3,7 +3,7 @@
 #ifndef SCM_LOAD_H
 #define SCM_LOAD_H
 
-/* Copyright (C) 1995,1996,1998,2000,2001, 2006, 2008, 2009, 2010, 2011 Free 
Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1998,2000,2001, 2006, 2008, 2009, 2010, 2011, 2013 
Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -34,6 +34,7 @@ SCM_API SCM scm_sys_package_data_dir (void);
 SCM_API SCM scm_sys_library_dir (void);
 SCM_API SCM scm_sys_site_dir (void);
 SCM_API SCM scm_sys_global_site_dir (void);
+SCM_API SCM scm_sys_site_ccache_dir (void);
 SCM_API SCM scm_search_path (SCM path, SCM filename, SCM rest);
 SCM_API SCM scm_sys_search_load_path (SCM filename);
 SCM_API SCM scm_primitive_load_path (SCM filename_and_exception_on_not_found);
diff --git a/libguile/memoize.c b/libguile/memoize.c
index af68610..f20241c 100644
--- a/libguile/memoize.c
+++ b/libguile/memoize.c
@@ -1,5 +1,5 @@
 /* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
- *   2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
+ *   2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
  *   Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
@@ -284,14 +284,33 @@ memoize (SCM exp, SCM env)
                           memoize (REF (exp, SEQ, TAIL), env));
 
     case SCM_EXPANDED_LAMBDA:
-      /* The body will be a lambda-case. */
+      /* The body will be a lambda-case or #f. */
       {
-       SCM meta, docstring, proc;
+       SCM meta, docstring, body, proc;
 
        meta = REF (exp, LAMBDA, META);
        docstring = scm_assoc_ref (meta, scm_sym_documentation);
 
-       proc = memoize (REF (exp, LAMBDA, BODY), env);
+        body = REF (exp, LAMBDA, BODY);
+        if (scm_is_false (body))
+          /* Give a body to case-lambda with no clauses.  */
+          proc = MAKMEMO_LAMBDA
+            (MAKMEMO_CALL
+             (MAKMEMO_MOD_REF (list_of_guile,
+                               scm_from_latin1_symbol ("throw"),
+                               SCM_BOOL_F),
+              5,
+              scm_list_5 (MAKMEMO_QUOTE (scm_args_number_key),
+                          MAKMEMO_QUOTE (SCM_BOOL_F),
+                          MAKMEMO_QUOTE (scm_from_latin1_string
+                                         ("Wrong number of arguments")),
+                          MAKMEMO_QUOTE (SCM_EOL),
+                          MAKMEMO_QUOTE (SCM_BOOL_F))),
+             FIXED_ARITY (0),
+             SCM_BOOL_F /* docstring */);
+        else
+          proc = memoize (body, env);
+
        if (scm_is_string (docstring))
          {
            SCM args = SCM_MEMOIZED_ARGS (proc);
@@ -910,7 +929,6 @@ void
 scm_init_memoize ()
 {
   scm_tc16_memoized = scm_make_smob_type ("%memoized", 0);
-  scm_set_smob_mark (scm_tc16_memoized, scm_markcdr);
   scm_set_smob_print (scm_tc16_memoized, scm_print_memoized);
 
   scm_tc16_memoizer = scm_make_smob_type ("memoizer", 0);
diff --git a/libguile/mkstemp.c b/libguile/mkstemp.c
index 6a573c6..a7eaf10 100644
--- a/libguile/mkstemp.c
+++ b/libguile/mkstemp.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1996, 1998, 2001, 2006 Free Software Foundation, 
Inc.
+/* Copyright (C) 1991, 1992, 1996, 1998, 2001, 2006, 2013 Free Software 
Foundation, Inc.
    This file is derived from mkstemps.c from the GNU Libiberty Library
    which in turn is derived from the GNU C Library.
 
@@ -112,7 +112,7 @@ mkstemp (template)
       v /= 62;
       XXXXXX[5] = letters[v % 62];
 
-      fd = open (template, O_RDWR|O_CREAT|O_EXCL, 0600);
+      fd = open (template, O_RDWR|O_CREAT|O_EXCL|O_BINARY, 0600);
       if (fd >= 0)
        /* The file does not exist.  */
        return fd;
diff --git a/libguile/net_db.c b/libguile/net_db.c
index 4d63aab..d7a12c5 100644
--- a/libguile/net_db.c
+++ b/libguile/net_db.c
@@ -1,6 +1,6 @@
 /* "net_db.c" network database support
  * Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2006, 2009,
- *   2010, 2011, 2012 Free Software Foundation, Inc.
+ *   2010, 2011, 2012, 2013 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -34,48 +34,36 @@
 #include <verify.h>
 #include <errno.h>
 
-#include "libguile/_scm.h"
-#include "libguile/feature.h"
-#include "libguile/strings.h"
-#include "libguile/vectors.h"
-#include "libguile/dynwind.h"
-
-#include "libguile/validate.h"
-#include "libguile/net_db.h"
-#include "libguile/socket.h"
-
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
 
 #include <sys/types.h>
 
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h>
-#else
 #include <sys/socket.h>
 #include <netdb.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
-#endif
 
-#ifdef __MINGW32__
-#include "win32-socket.h"
-#endif
+#include "libguile/_scm.h"
+#include "libguile/feature.h"
+#include "libguile/strings.h"
+#include "libguile/vectors.h"
+#include "libguile/dynwind.h"
 
-#if !defined (HAVE_H_ERRNO) && !defined (__MINGW32__) && !defined (__CYGWIN__)
-/* h_errno not found in netdb.h, maybe this will help.  */
-extern int h_errno;
-#endif
+#include "libguile/validate.h"
+#include "libguile/net_db.h"
+#include "libguile/socket.h"
+
+
+#if defined (HAVE_H_ERRNO)
+/* Only wrap gethostbyname / gethostbyaddr if h_errno is available.  */
 
-#if defined HAVE_HSTRERROR && !HAVE_DECL_HSTRERROR     \
-  && !defined __MINGW32__ && !defined __CYGWIN__
+#if defined HAVE_HSTRERROR && !HAVE_DECL_HSTRERROR
 /* Some OSes, such as Tru64 5.1b, lack a declaration for hstrerror(3).  */
 extern const char *hstrerror (int);
 #endif
 
-
-
 SCM_SYMBOL (scm_host_not_found_key, "host-not-found");
 SCM_SYMBOL (scm_try_again_key, "try-again");
 SCM_SYMBOL (scm_no_recovery_key, "no-recovery");
@@ -204,6 +192,8 @@ SCM_DEFINE (scm_gethost, "gethost", 0, 1, 0,
 }
 #undef FUNC_NAME
 
+#endif /* HAVE_H_ERRNO */
+
 
 /* In all subsequent getMUMBLE functions, when we're called with no
    arguments, we're supposed to traverse the tables entry by entry.
@@ -267,7 +257,7 @@ SCM_DEFINE (scm_getnet, "getnet", 0, 1, 0,
 #undef FUNC_NAME
 #endif
 
-#if defined (HAVE_GETPROTOENT) || defined (__MINGW32__)
+#if defined (HAVE_GETPROTOENT)
 SCM_DEFINE (scm_getproto, "getproto", 0, 1, 0, 
             (SCM protocol),
            "@deffnx {Scheme Procedure} getprotobyname name\n"
@@ -318,7 +308,7 @@ SCM_DEFINE (scm_getproto, "getproto", 0, 1, 0,
 #undef FUNC_NAME
 #endif
 
-#if defined (HAVE_GETSERVENT) || defined (__MINGW32__)
+#if defined (HAVE_GETSERVENT)
 static SCM
 scm_return_entry (struct servent *entry)
 {
@@ -420,7 +410,7 @@ SCM_DEFINE (scm_setnet, "setnet", 0, 1, 0,
 #undef FUNC_NAME
 #endif
 
-#if defined (HAVE_SETPROTOENT) && defined (HAVE_ENDPROTOENT) || defined 
(__MINGW32__)
+#if defined (HAVE_SETPROTOENT) && defined (HAVE_ENDPROTOENT)
 SCM_DEFINE (scm_setproto, "setproto", 0, 1, 0, 
             (SCM stayopen),
            "If @var{stayopen} is omitted, this is equivalent to 
@code{endprotoent}.\n"
@@ -436,7 +426,7 @@ SCM_DEFINE (scm_setproto, "setproto", 0, 1, 0,
 #undef FUNC_NAME
 #endif
 
-#if defined (HAVE_SETSERVENT) && defined (HAVE_ENDSERVENT) || defined 
(__MINGW32__)
+#if defined (HAVE_SETSERVENT) && defined (HAVE_ENDSERVENT)
 SCM_DEFINE (scm_setserv, "setserv", 0, 1, 0, 
             (SCM stayopen),
            "If @var{stayopen} is omitted, this is equivalent to 
@code{endservent}.\n"
@@ -605,8 +595,10 @@ SCM_DEFINE (scm_getaddrinfo, "getaddrinfo", 1, 5, 0,
            "@item EAI_SOCKTYPE\n"
            "@var{hint_socktype} was not recognized.\n\n"
            "@item EAI_SYSTEM\n"
-           "A system error occurred; the error code can be found in "
-           "@code{errno}.\n"
+           "A system error occurred.  In C, the error code can be found in "
+           "@code{errno}; this value is not accessible from Scheme, but in\n"
+           "practice it provides little information about the actual error "
+           "cause.\n\n"          /* see <http://bugs.gnu.org/13958>. */
            "@end table\n"
            "\n"
            "Users are encouraged to read the "
diff --git a/libguile/numbers.c b/libguile/numbers.c
index 01f8e05..d941133 100644
--- a/libguile/numbers.c
+++ b/libguile/numbers.c
@@ -1,4 +1,6 @@
-/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005, 2006, 
2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
+ *   2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012,
+ *   2013 Free Software Foundation, Inc.
  *
  * Portions Copyright 1990, 1991, 1992, 1993 by AT&T Bell Laboratories
  * and Bellcore.  See scm_divide.
@@ -56,6 +58,8 @@
 #include <complex.h>
 #endif
 
+#include <stdarg.h>
+
 #include "libguile/_scm.h"
 #include "libguile/feature.h"
 #include "libguile/ports.h"
@@ -81,6 +85,9 @@
 #define M_PI       3.14159265358979323846
 #endif
 
+/* FIXME: We assume that FLT_RADIX is 2 */
+verify (FLT_RADIX == 2);
+
 typedef scm_t_signed_bits scm_t_inum;
 #define scm_from_inum(x) (scm_from_signed_integer (x))
 
@@ -93,6 +100,31 @@ typedef scm_t_signed_bits scm_t_inum;
 #define DOUBLE_IS_POSITIVE_INFINITY(x) (isinf(x) && ((x) > 0))
 #define DOUBLE_IS_NEGATIVE_INFINITY(x) (isinf(x) && ((x) < 0))
 
+
+#if ! HAVE_DECL_MPZ_INITS
+
+/* GMP < 5.0.0 lacks `mpz_inits' and `mpz_clears'.  Provide them.  */
+
+#define VARARG_MPZ_ITERATOR(func)              \
+  static void                                  \
+  func ## s (mpz_t x, ...)                     \
+  {                                            \
+    va_list  ap;                               \
+                                               \
+    va_start (ap, x);                          \
+    while (x != NULL)                          \
+      {                                                \
+       func (x);                               \
+       x = va_arg (ap, mpz_ptr);               \
+      }                                                \
+    va_end (ap);                               \
+  }
+
+VARARG_MPZ_ITERATOR (mpz_init)
+VARARG_MPZ_ITERATOR (mpz_clear)
+
+#endif
+
 
 
 /*
@@ -327,81 +359,52 @@ scm_i_dbl2num (double u)
     return scm_i_dbl2big (u);
 }
 
-/* scm_i_big2dbl() rounds to the closest representable double, in accordance
-   with R5RS exact->inexact.
-
-   The approach is to use mpz_get_d to pick out the high DBL_MANT_DIG bits
-   (ie. truncate towards zero), then adjust to get the closest double by
-   examining the next lower bit and adding 1 (to the absolute value) if
-   necessary.
-
-   Bignums exactly half way between representable doubles are rounded to the
-   next higher absolute value (ie. away from zero).  This seems like an
-   adequate interpretation of R5RS "numerically closest", and it's easier
-   and faster than a full "nearest-even" style.
+static SCM round_right_shift_exact_integer (SCM n, long count);
 
-   The bit test must be done on the absolute value of the mpz_t, which means
-   we need to use mpz_getlimbn.  mpz_tstbit is not right, it treats
-   negatives as twos complement.
+/* scm_i_big2dbl_2exp() is like frexp for bignums: it converts the
+   bignum b into a normalized significand and exponent such that
+   b = significand * 2^exponent and 1/2 <= abs(significand) < 1.
+   The return value is the significand rounded to the closest
+   representable double, and the exponent is placed into *expon_p.
+   If b is zero, then the returned exponent and significand are both
+   zero. */
 
-   In GMP before 4.2, mpz_get_d rounding was unspecified.  It ended up
-   following the hardware rounding mode, but applied to the absolute
-   value of the mpz_t operand.  This is not what we want so we put the
-   high DBL_MANT_DIG bits into a temporary.  Starting with GMP 4.2
-   (released in March 2006) mpz_get_d now always truncates towards zero.
-
-   ENHANCE-ME: The temporary init+clear to force the rounding in GMP
-   before 4.2 is a slowdown.  It'd be faster to pick out the relevant
-   high bits with mpz_getlimbn.  */
-
-double
-scm_i_big2dbl (SCM b)
+static double
+scm_i_big2dbl_2exp (SCM b, long *expon_p)
 {
-  double result;
-  size_t bits;
-
-  bits = mpz_sizeinbase (SCM_I_BIG_MPZ (b), 2);
-
-#if 1
-  {
-    /* For GMP earlier than 4.2, force truncation towards zero */
-
-    /* FIXME: DBL_MANT_DIG is the number of base-`FLT_RADIX' digits,
-       _not_ the number of bits, so this code will break badly on a
-       system with non-binary doubles.  */
-
-    mpz_t  tmp;
-    if (bits > DBL_MANT_DIG)
-      {
-        size_t  shift = bits - DBL_MANT_DIG;
-        mpz_init2 (tmp, DBL_MANT_DIG);
-        mpz_tdiv_q_2exp (tmp, SCM_I_BIG_MPZ (b), shift);
-        result = ldexp (mpz_get_d (tmp), shift);
-        mpz_clear (tmp);
-      }
-    else
-      {
-        result = mpz_get_d (SCM_I_BIG_MPZ (b));
-      }
-  }
-#else
-  /* GMP 4.2 or later */
-  result = mpz_get_d (SCM_I_BIG_MPZ (b));
-#endif
+  size_t bits = mpz_sizeinbase (SCM_I_BIG_MPZ (b), 2);
+  size_t shift = 0;
 
   if (bits > DBL_MANT_DIG)
     {
-      unsigned long  pos = bits - DBL_MANT_DIG - 1;
-      /* test bit number "pos" in absolute value */
-      if (mpz_getlimbn (SCM_I_BIG_MPZ (b), pos / GMP_NUMB_BITS)
-          & ((mp_limb_t) 1 << (pos % GMP_NUMB_BITS)))
+      shift = bits - DBL_MANT_DIG;
+      b = round_right_shift_exact_integer (b, shift);
+      if (SCM_I_INUMP (b))
         {
-          result += ldexp ((double) mpz_sgn (SCM_I_BIG_MPZ (b)), pos + 1);
+          int expon;
+          double signif = frexp (SCM_I_INUM (b), &expon);
+          *expon_p = expon + shift;
+          return signif;
         }
     }
 
-  scm_remember_upto_here_1 (b);
-  return result;
+  {
+    long expon;
+    double signif = mpz_get_d_2exp (&expon, SCM_I_BIG_MPZ (b));
+    scm_remember_upto_here_1 (b);
+    *expon_p = expon + shift;
+    return signif;
+  }
+}
+
+/* scm_i_big2dbl() rounds to the closest representable double,
+   in accordance with R5RS exact->inexact.  */
+double
+scm_i_big2dbl (SCM b)
+{
+  long expon;
+  double signif = scm_i_big2dbl_2exp (b, &expon);
+  return ldexp (signif, expon);
 }
 
 SCM
@@ -436,107 +439,212 @@ scm_i_mpz2num (mpz_t b)
   }
 }
 
-/* this is needed when we want scm_divide to make a float, not a ratio, even 
if passed two ints */
-static SCM scm_divide2real (SCM x, SCM y);
-
+/* Make the ratio NUMERATOR/DENOMINATOR, where:
+    1. NUMERATOR and DENOMINATOR are exact integers
+    2. NUMERATOR and DENOMINATOR are reduced to lowest terms: gcd(n,d) == 1 */
 static SCM
-scm_i_make_ratio (SCM numerator, SCM denominator)
-#define FUNC_NAME "make-ratio"
+scm_i_make_ratio_already_reduced (SCM numerator, SCM denominator)
 {
-  /* First make sure the arguments are proper.
-   */
-  if (SCM_I_INUMP (denominator))
+  /* Flip signs so that the denominator is positive. */
+  if (scm_is_false (scm_positive_p (denominator)))
     {
-      if (scm_is_eq (denominator, SCM_INUM0))
+      if (SCM_UNLIKELY (scm_is_eq (denominator, SCM_INUM0)))
        scm_num_overflow ("make-ratio");
-      if (scm_is_eq (denominator, SCM_INUM1))
-       return numerator;
-    }
-  else 
-    {
-      if (!(SCM_BIGP(denominator)))
-       SCM_WRONG_TYPE_ARG (2, denominator);
+      else
+       {
+         numerator = scm_difference (numerator, SCM_UNDEFINED);
+         denominator = scm_difference (denominator, SCM_UNDEFINED);
+       }
     }
-  if (!SCM_I_INUMP (numerator) && !SCM_BIGP (numerator))
-    SCM_WRONG_TYPE_ARG (1, numerator);
 
-  /* Then flip signs so that the denominator is positive.
-   */
-  if (scm_is_true (scm_negative_p (denominator)))
-    {
-      numerator = scm_difference (numerator, SCM_UNDEFINED);
-      denominator = scm_difference (denominator, SCM_UNDEFINED);
-    }
+  /* Check for the integer case */
+  if (scm_is_eq (denominator, SCM_INUM1))
+    return numerator;
 
-  /* Now consider for each of the four fixnum/bignum combinations
-     whether the rational number is really an integer.
-  */
-  if (SCM_I_INUMP (numerator))
+  return scm_double_cell (scm_tc16_fraction,
+                         SCM_UNPACK (numerator),
+                         SCM_UNPACK (denominator), 0);
+}
+
+static SCM scm_exact_integer_quotient (SCM x, SCM y);
+
+/* Make the ratio NUMERATOR/DENOMINATOR */
+static SCM
+scm_i_make_ratio (SCM numerator, SCM denominator)
+#define FUNC_NAME "make-ratio"
+{
+  /* Make sure the arguments are proper */
+  if (!SCM_LIKELY (SCM_I_INUMP (numerator) || SCM_BIGP (numerator)))
+    SCM_WRONG_TYPE_ARG (1, numerator);
+  else if (!SCM_LIKELY (SCM_I_INUMP (denominator) || SCM_BIGP (denominator)))
+    SCM_WRONG_TYPE_ARG (2, denominator);
+  else
     {
-      scm_t_inum x = SCM_I_INUM (numerator);
-      if (scm_is_eq (numerator, SCM_INUM0))
-       return SCM_INUM0;
-      if (SCM_I_INUMP (denominator))
+      SCM the_gcd = scm_gcd (numerator, denominator);
+      if (!(scm_is_eq (the_gcd, SCM_INUM1)))
        {
-         scm_t_inum y;
-         y = SCM_I_INUM (denominator);
-         if (x == y)
-           return SCM_INUM1;
-         if ((x % y) == 0)
-           return SCM_I_MAKINUM (x / y);
+         /* Reduce to lowest terms */
+         numerator = scm_exact_integer_quotient (numerator, the_gcd);
+         denominator = scm_exact_integer_quotient (denominator, the_gcd);
        }
-      else
-        {
-          /* When x == SCM_MOST_NEGATIVE_FIXNUM we could have the negative
-             of that value for the denominator, as a bignum.  Apart from
-             that case, abs(bignum) > abs(inum) so inum/bignum is not an
-             integer.  */
-          if (x == SCM_MOST_NEGATIVE_FIXNUM
-              && mpz_cmp_ui (SCM_I_BIG_MPZ (denominator),
-                             - SCM_MOST_NEGATIVE_FIXNUM) == 0)
-           return SCM_I_MAKINUM(-1);
-        }
+      return scm_i_make_ratio_already_reduced (numerator, denominator);
     }
-  else if (SCM_BIGP (numerator))
+}
+#undef FUNC_NAME
+
+static mpz_t scm_i_divide2double_lo2b;
+
+/* Return the double that is closest to the exact rational N/D, with
+   ties rounded toward even mantissas.  N and D must be exact
+   integers. */
+static double
+scm_i_divide2double (SCM n, SCM d)
+{
+  int neg;
+  mpz_t nn, dd, lo, hi, x;
+  ssize_t e;
+
+  if (SCM_LIKELY (SCM_I_INUMP (d)))
     {
-      if (SCM_I_INUMP (denominator))
-       {
-         scm_t_inum yy = SCM_I_INUM (denominator);
-         if (mpz_divisible_ui_p (SCM_I_BIG_MPZ (numerator), yy))
-           return scm_divide (numerator, denominator);
-       }
-      else
-       {
-         if (scm_is_eq (numerator, denominator))
-           return SCM_INUM1;
-         if (mpz_divisible_p (SCM_I_BIG_MPZ (numerator),
-                              SCM_I_BIG_MPZ (denominator)))
-           return scm_divide(numerator, denominator);
-       }
+      if (SCM_LIKELY (SCM_I_INUMP (n)
+                      && (SCM_I_FIXNUM_BIT-1 <= DBL_MANT_DIG
+                          || (SCM_I_INUM (n) < (1L << DBL_MANT_DIG)
+                              && SCM_I_INUM (d) < (1L << DBL_MANT_DIG)))))
+        /* If both N and D can be losslessly converted to doubles, then
+           we can rely on IEEE floating point to do proper rounding much
+           faster than we can. */
+        return ((double) SCM_I_INUM (n)) / ((double) SCM_I_INUM (d));
+
+      if (SCM_UNLIKELY (scm_is_eq (d, SCM_INUM0)))
+        {
+          if (scm_is_true (scm_positive_p (n)))
+            return 1.0 / 0.0;
+          else if (scm_is_true (scm_negative_p (n)))
+            return -1.0 / 0.0;
+          else
+            return 0.0 / 0.0;
+        }
+
+      mpz_init_set_si (dd, SCM_I_INUM (d));
     }
+  else
+    mpz_init_set (dd, SCM_I_BIG_MPZ (d));
 
-  /* No, it's a proper fraction.
-   */
+  if (SCM_I_INUMP (n))
+    mpz_init_set_si (nn, SCM_I_INUM (n));
+  else
+    mpz_init_set (nn, SCM_I_BIG_MPZ (n));
+
+  neg = (mpz_sgn (nn) < 0) ^ (mpz_sgn (dd) < 0);
+  mpz_abs (nn, nn);
+  mpz_abs (dd, dd);
+
+  /* Now we need to find the value of e such that:
+ 
+     For e <= 0:
+          b^{p-1} - 1/2b  <=      b^-e n / d  <  b^p - 1/2            [1A]
+             (2 b^p - 1)  <=  2 b b^-e n / d  <  (2 b^p - 1) b        [2A]
+           (2 b^p - 1) d  <=  2 b b^-e n      <  (2 b^p - 1) d b      [3A]
+
+     For e >= 0:
+          b^{p-1} - 1/2b  <=      n / b^e d   <  b^p - 1/2            [1B]
+             (2 b^p - 1)  <=  2 b n / b^e d   <  (2 b^p - 1) b        [2B]
+       (2 b^p - 1) d b^e  <=  2 b n           <  (2 b^p - 1) d b b^e  [3B]
+
+         where:  p = DBL_MANT_DIG
+                 b = FLT_RADIX  (here assumed to be 2)
+
+     After rounding, the mantissa must be an integer between b^{p-1} and
+     (b^p - 1), except for subnormal numbers.  In the inequations [1A]
+     and [1B], the middle expression represents the mantissa *before*
+     rounding, and therefore is bounded by the range of values that will
+     round to a floating-point number with the exponent e.  The upper
+     bound is (b^p - 1 + 1/2) = (b^p - 1/2), and is exclusive because
+     ties will round up to the next power of b.  The lower bound is
+     (b^{p-1} - 1/2b), and is inclusive because ties will round toward
+     this power of b.  Here we subtract 1/2b instead of 1/2 because it
+     is in the range of the next smaller exponent, where the
+     representable numbers are closer together by a factor of b.
+
+     Inequations [2A] and [2B] are derived from [1A] and [1B] by
+     multiplying by 2b, and in [3A] and [3B] we multiply by the
+     denominator of the middle value to obtain integer expressions.
+
+     In the code below, we refer to the three expressions in [3A] or
+     [3B] as lo, x, and hi.  If the number is normalizable, we will
+     achieve the goal: lo <= x < hi */
+
+  /* Make an initial guess for e */
+  e = mpz_sizeinbase (nn, 2) - mpz_sizeinbase (dd, 2) - (DBL_MANT_DIG-1);
+  if (e < DBL_MIN_EXP - DBL_MANT_DIG)
+    e = DBL_MIN_EXP - DBL_MANT_DIG;
+
+  /* Compute the initial values of lo, x, and hi
+     based on the initial guess of e */
+  mpz_inits (lo, hi, x, NULL);
+  mpz_mul_2exp (x, nn, 2 + ((e < 0) ? -e : 0));
+  mpz_mul (lo, dd, scm_i_divide2double_lo2b);
+  if (e > 0)
+    mpz_mul_2exp (lo, lo, e);
+  mpz_mul_2exp (hi, lo, 1);
+
+  /* Adjust e as needed to satisfy the inequality lo <= x < hi,
+     (but without making e less then the minimum exponent) */
+  while (mpz_cmp (x, lo) < 0 && e > DBL_MIN_EXP - DBL_MANT_DIG)
+    {
+      mpz_mul_2exp (x, x, 1);
+      e--;
+    }
+  while (mpz_cmp (x, hi) >= 0)
+    {
+      /* If we ever used lo's value again,
+         we would need to double lo here. */
+      mpz_mul_2exp (hi, hi, 1);
+      e++;
+    }
+
+  /* Now compute the rounded mantissa:
+     n / b^e d   (if e >= 0)
+     n b^-e / d  (if e <= 0) */
   {
-    SCM divisor = scm_gcd (numerator, denominator);
-    if (!(scm_is_eq (divisor, SCM_INUM1)))
-      {
-       numerator = scm_divide (numerator, divisor);
-       denominator = scm_divide (denominator, divisor);
-      }
-      
-    return scm_double_cell (scm_tc16_fraction,
-                           SCM_UNPACK (numerator),
-                           SCM_UNPACK (denominator), 0);
+    int cmp;
+    double result;
+
+    if (e < 0)
+      mpz_mul_2exp (nn, nn, -e);
+    else
+      mpz_mul_2exp (dd, dd, e);
+
+    /* mpz does not directly support rounded right
+       shifts, so we have to do it the hard way.
+       For efficiency, we reuse lo and hi.
+       hi == quotient, lo == remainder */
+    mpz_fdiv_qr (hi, lo, nn, dd);
+
+    /* The fractional part of the unrounded mantissa would be
+       remainder/dividend, i.e. lo/dd.  So we have a tie if
+       lo/dd = 1/2.  Multiplying both sides by 2*dd yields the
+       integer expression 2*lo = dd.  Here we do that comparison
+       to decide whether to round up or down. */
+    mpz_mul_2exp (lo, lo, 1);
+    cmp = mpz_cmp (lo, dd);
+    if (cmp > 0 || (cmp == 0 && mpz_odd_p (hi)))
+      mpz_add_ui (hi, hi, 1);
+
+    result = ldexp (mpz_get_d (hi), e);
+    if (neg)
+      result = -result;
+
+    mpz_clears (nn, dd, lo, hi, x, NULL);
+    return result;
   }
 }
-#undef FUNC_NAME
 
 double
 scm_i_fraction2double (SCM z)
 {
-  return scm_to_double (scm_divide2real (SCM_FRACTION_NUMERATOR (z), 
-                                        SCM_FRACTION_DENOMINATOR (z)));
+  return scm_i_divide2double (SCM_FRACTION_NUMERATOR (z),
+                              SCM_FRACTION_DENOMINATOR (z));
 }
 
 static int
@@ -820,8 +928,9 @@ SCM_PRIMITIVE_GENERIC (scm_abs, "abs", 1, 0, 0,
     {
       if (scm_is_false (scm_negative_p (SCM_FRACTION_NUMERATOR (x))))
        return x;
-      return scm_i_make_ratio (scm_difference (SCM_FRACTION_NUMERATOR (x), 
SCM_UNDEFINED),
-                            SCM_FRACTION_DENOMINATOR (x));
+      return scm_i_make_ratio_already_reduced
+       (scm_difference (SCM_FRACTION_NUMERATOR (x), SCM_UNDEFINED),
+        SCM_FRACTION_DENOMINATOR (x));
     }
   else
     return scm_wta_dispatch_1 (g_scm_abs, x, 1, s_scm_abs);
@@ -889,6 +998,84 @@ SCM_PRIMITIVE_GENERIC (scm_modulo, "modulo", 2, 0, 0,
 }
 #undef FUNC_NAME
 
+/* Return the exact integer q such that n = q*d, for exact integers n
+   and d, where d is known in advance to divide n evenly (with zero
+   remainder).  For large integers, this can be computed more
+   efficiently than when the remainder is unknown. */
+static SCM
+scm_exact_integer_quotient (SCM n, SCM d)
+#define FUNC_NAME "exact-integer-quotient"
+{
+  if (SCM_LIKELY (SCM_I_INUMP (n)))
+    {
+      scm_t_inum nn = SCM_I_INUM (n);
+      if (SCM_LIKELY (SCM_I_INUMP (d)))
+       {
+         scm_t_inum dd = SCM_I_INUM (d);
+         if (SCM_UNLIKELY (dd == 0))
+           scm_num_overflow ("exact-integer-quotient");
+         else
+           {
+             scm_t_inum qq = nn / dd;
+             if (SCM_LIKELY (SCM_FIXABLE (qq)))
+               return SCM_I_MAKINUM (qq);
+             else
+               return scm_i_inum2big (qq);
+           }
+       }
+      else if (SCM_LIKELY (SCM_BIGP (d)))
+       {
+         /* n is an inum and d is a bignum.  Given that d is known to
+            divide n evenly, there are only two possibilities: n is 0,
+            or else n is fixnum-min and d is abs(fixnum-min). */
+         if (nn == 0)
+           return SCM_INUM0;
+         else
+           return SCM_I_MAKINUM (-1);
+       }
+      else
+       SCM_WRONG_TYPE_ARG (2, d);
+    }
+  else if (SCM_LIKELY (SCM_BIGP (n)))
+    {
+      if (SCM_LIKELY (SCM_I_INUMP (d)))
+       {
+         scm_t_inum dd = SCM_I_INUM (d);
+         if (SCM_UNLIKELY (dd == 0))
+           scm_num_overflow ("exact-integer-quotient");
+         else if (SCM_UNLIKELY (dd == 1))
+           return n;
+         else
+           {
+             SCM q = scm_i_mkbig ();
+             if (dd > 0)
+               mpz_divexact_ui (SCM_I_BIG_MPZ (q), SCM_I_BIG_MPZ (n), dd);
+             else
+               {
+                 mpz_divexact_ui (SCM_I_BIG_MPZ (q), SCM_I_BIG_MPZ (n), -dd);
+                 mpz_neg (SCM_I_BIG_MPZ (q), SCM_I_BIG_MPZ (q));
+               }
+             scm_remember_upto_here_1 (n);
+             return scm_i_normbig (q);
+           }
+       }
+      else if (SCM_LIKELY (SCM_BIGP (d)))
+       {
+         SCM q = scm_i_mkbig ();
+         mpz_divexact (SCM_I_BIG_MPZ (q),
+                       SCM_I_BIG_MPZ (n),
+                       SCM_I_BIG_MPZ (d));
+         scm_remember_upto_here_2 (n, d);
+         return scm_i_normbig (q);
+       }
+      else
+       SCM_WRONG_TYPE_ARG (2, d);
+    }
+  else
+    SCM_WRONG_TYPE_ARG (1, n);
+}
+#undef FUNC_NAME
+
 /* two_valued_wta_dispatch_2 is a version of SCM_WTA_DISPATCH_2 for
    two-valued functions.  It is called from primitive generics that take
    two arguments and return two values, when the core procedure is
@@ -3888,52 +4075,58 @@ SCM_PRIMITIVE_GENERIC (scm_i_gcd, "gcd", 0, 2, 1,
 SCM
 scm_gcd (SCM x, SCM y)
 {
-  if (SCM_UNBNDP (y))
+  if (SCM_UNLIKELY (SCM_UNBNDP (y)))
     return SCM_UNBNDP (x) ? SCM_INUM0 : scm_abs (x);
   
-  if (SCM_I_INUMP (x))
+  if (SCM_LIKELY (SCM_I_INUMP (x)))
     {
-      if (SCM_I_INUMP (y))
+      if (SCM_LIKELY (SCM_I_INUMP (y)))
         {
           scm_t_inum xx = SCM_I_INUM (x);
           scm_t_inum yy = SCM_I_INUM (y);
           scm_t_inum u = xx < 0 ? -xx : xx;
           scm_t_inum v = yy < 0 ? -yy : yy;
           scm_t_inum result;
-          if (xx == 0)
+          if (SCM_UNLIKELY (xx == 0))
            result = v;
-         else if (yy == 0)
+         else if (SCM_UNLIKELY (yy == 0))
            result = u;
          else
            {
-             scm_t_inum k = 1;
-             scm_t_inum t;
+             int k = 0;
              /* Determine a common factor 2^k */
-             while (!(1 & (u | v)))
+             while (((u | v) & 1) == 0)
                {
-                 k <<= 1;
+                 k++;
                  u >>= 1;
                  v >>= 1;
                }
              /* Now, any factor 2^n can be eliminated */
-             if (u & 1)
-               t = -v;
+             if ((u & 1) == 0)
+               while ((u & 1) == 0)
+                 u >>= 1;
              else
+               while ((v & 1) == 0)
+                 v >>= 1;
+             /* Both u and v are now odd.  Subtract the smaller one
+                from the larger one to produce an even number, remove
+                more factors of two, and repeat. */
+             while (u != v)
                {
-                 t = u;
-               b3:
-                 t = SCM_SRS (t, 1);
+                 if (u > v)
+                   {
+                     u -= v;
+                     while ((u & 1) == 0)
+                       u >>= 1;
+                   }
+                 else
+                   {
+                     v -= u;
+                     while ((v & 1) == 0)
+                       v >>= 1;
+                   }
                }
-             if (!(1 & t))
-               goto b3;
-             if (t > 0)
-               u = t;
-             else
-               v = -t;
-             t = u - v;
-             if (t != 0)
-               goto b3;
-             result = u * k;
+             result = u << k;
            }
           return (SCM_POSFIXABLE (result)
                  ? SCM_I_MAKINUM (result)
@@ -4666,6 +4859,26 @@ SCM_DEFINE (scm_integer_expt, "integer-expt", 2, 0, 0,
       else  /* return NaN for (0 ^ k) for negative k per R6RS */
        return scm_nan ();
     }
+  else if (SCM_FRACTIONP (n))
+    {
+      /* Optimize the fraction case by (a/b)^k ==> (a^k)/(b^k), to avoid
+         needless reduction of intermediate products to lowest terms.
+         If a and b have no common factors, then a^k and b^k have no
+         common factors.  Use 'scm_i_make_ratio_already_reduced' to
+         construct the final result, so that no gcd computations are
+         needed to exponentiate a fraction.  */
+      if (scm_is_true (scm_positive_p (k)))
+       return scm_i_make_ratio_already_reduced
+         (scm_integer_expt (SCM_FRACTION_NUMERATOR (n), k),
+          scm_integer_expt (SCM_FRACTION_DENOMINATOR (n), k));
+      else
+       {
+         k = scm_difference (k, SCM_UNDEFINED);
+         return scm_i_make_ratio_already_reduced
+           (scm_integer_expt (SCM_FRACTION_DENOMINATOR (n), k),
+            scm_integer_expt (SCM_FRACTION_NUMERATOR (n), k));
+       }
+    }
 
   if (SCM_I_INUMP (k))
     i2 = SCM_I_INUM (k);
@@ -4723,19 +4936,119 @@ SCM_DEFINE (scm_integer_expt, "integer-expt", 2, 0, 0,
 }
 #undef FUNC_NAME
 
+/* Efficiently compute (N * 2^COUNT),
+   where N is an exact integer, and COUNT > 0. */
+static SCM
+left_shift_exact_integer (SCM n, long count)
+{
+  if (SCM_I_INUMP (n))
+    {
+      scm_t_inum nn = SCM_I_INUM (n);
+
+      /* Left shift of count >= SCM_I_FIXNUM_BIT-1 will always
+         overflow a non-zero fixnum.  For smaller shifts we check the
+         bits going into positions above SCM_I_FIXNUM_BIT-1.  If they're
+         all 0s for nn>=0, or all 1s for nn<0 then there's no overflow.
+         Those bits are "nn >> (SCM_I_FIXNUM_BIT-1 - count)".  */
+
+      if (nn == 0)
+        return n;
+      else if (count < SCM_I_FIXNUM_BIT-1 &&
+               ((scm_t_bits) (SCM_SRS (nn, (SCM_I_FIXNUM_BIT-1 - count)) + 1)
+                <= 1))
+        return SCM_I_MAKINUM (nn << count);
+      else
+        {
+          SCM result = scm_i_inum2big (nn);
+          mpz_mul_2exp (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (result),
+                        count);
+          return result;
+        }
+    }
+  else if (SCM_BIGP (n))
+    {
+      SCM result = scm_i_mkbig ();
+      mpz_mul_2exp (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (n), count);
+      scm_remember_upto_here_1 (n);
+      return result;
+    }
+  else
+    scm_syserror ("left_shift_exact_integer");
+}
+
+/* Efficiently compute floor (N / 2^COUNT),
+   where N is an exact integer and COUNT > 0. */
+static SCM
+floor_right_shift_exact_integer (SCM n, long count)
+{
+  if (SCM_I_INUMP (n))
+    {
+      scm_t_inum nn = SCM_I_INUM (n);
+
+      if (count >= SCM_I_FIXNUM_BIT)
+        return (nn >= 0 ? SCM_INUM0 : SCM_I_MAKINUM (-1));
+      else
+        return SCM_I_MAKINUM (SCM_SRS (nn, count));
+    }
+  else if (SCM_BIGP (n))
+    {
+      SCM result = scm_i_mkbig ();
+      mpz_fdiv_q_2exp (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (n),
+                       count);
+      scm_remember_upto_here_1 (n);
+      return scm_i_normbig (result);
+    }
+  else
+    scm_syserror ("floor_right_shift_exact_integer");
+}
+
+/* Efficiently compute round (N / 2^COUNT),
+   where N is an exact integer and COUNT > 0. */
+static SCM
+round_right_shift_exact_integer (SCM n, long count)
+{
+  if (SCM_I_INUMP (n))
+    {
+      if (count >= SCM_I_FIXNUM_BIT)
+        return SCM_INUM0;
+      else
+        {
+          scm_t_inum nn = SCM_I_INUM (n);
+          scm_t_inum qq = SCM_SRS (nn, count);
+
+          if (0 == (nn & (1L << (count-1))))
+            return SCM_I_MAKINUM (qq);                /* round down */
+          else if (nn & ((1L << (count-1)) - 1))
+            return SCM_I_MAKINUM (qq + 1);            /* round up */
+          else
+            return SCM_I_MAKINUM ((~1L) & (qq + 1));  /* round to even */
+        }
+    }
+  else if (SCM_BIGP (n))
+    {
+      SCM q = scm_i_mkbig ();
+
+      mpz_fdiv_q_2exp (SCM_I_BIG_MPZ (q), SCM_I_BIG_MPZ (n), count);
+      if (mpz_tstbit (SCM_I_BIG_MPZ (n), count-1)
+          && (mpz_odd_p (SCM_I_BIG_MPZ (q))
+              || (mpz_scan1 (SCM_I_BIG_MPZ (n), 0) < count-1)))
+        mpz_add_ui (SCM_I_BIG_MPZ (q), SCM_I_BIG_MPZ (q), 1);
+      scm_remember_upto_here_1 (n);
+      return scm_i_normbig (q);
+    }
+  else
+    scm_syserror ("round_right_shift_exact_integer");
+}
+
 SCM_DEFINE (scm_ash, "ash", 2, 0, 0,
-            (SCM n, SCM cnt),
-           "Return @var{n} shifted left by @var{cnt} bits, or shifted right\n"
-           "if @var{cnt} is negative.  This is an ``arithmetic'' shift.\n"
-           "\n"
-           "This is effectively a multiplication by address@hidden, and when\n"
-           "@var{cnt} is negative it's a division, rounded towards negative\n"
-           "infinity.  (Note that this is not the same rounding as\n"
-           "@code{quotient} does.)\n"
+            (SCM n, SCM count),
+           "Return @math{floor(@var{n} * address@hidden)}.\n"
+           "@var{n} and @var{count} must be exact integers.\n"
            "\n"
-           "With @var{n} viewed as an infinite precision twos complement,\n"
-           "@code{ash} means a left shift introducing zero bits, or a right\n"
-           "shift dropping bits.\n"
+           "With @var{n} viewed as an infinite-precision twos-complement\n"
+           "integer, @code{ash} means a left shift introducing zero bits\n"
+           "when @var{count} is positive, or a right shift dropping bits\n"
+           "when @var{count} is negative.  This is an ``arithmetic'' shift.\n"
            "\n"
            "@lisp\n"
            "(number->string (ash #b1 3) 2)     @result{} \"1000\"\n"
@@ -4746,79 +5059,57 @@ SCM_DEFINE (scm_ash, "ash", 2, 0, 0,
            "@end lisp")
 #define FUNC_NAME s_scm_ash
 {
-  long bits_to_shift;
-  bits_to_shift = scm_to_long (cnt);
-
-  if (SCM_I_INUMP (n))
+  if (SCM_I_INUMP (n) || SCM_BIGP (n))
     {
-      scm_t_inum nn = SCM_I_INUM (n);
+      long bits_to_shift = scm_to_long (count);
 
       if (bits_to_shift > 0)
-        {
-          /* Left shift of bits_to_shift >= SCM_I_FIXNUM_BIT-1 will always
-             overflow a non-zero fixnum.  For smaller shifts we check the
-             bits going into positions above SCM_I_FIXNUM_BIT-1.  If they're
-             all 0s for nn>=0, or all 1s for nn<0 then there's no overflow.
-             Those bits are "nn >> (SCM_I_FIXNUM_BIT-1 -
-             bits_to_shift)".  */
-
-          if (nn == 0)
-            return n;
-
-          if (bits_to_shift < SCM_I_FIXNUM_BIT-1
-              && ((scm_t_bits)
-                  (SCM_SRS (nn, (SCM_I_FIXNUM_BIT-1 - bits_to_shift)) + 1)
-                  <= 1))
-            {
-              return SCM_I_MAKINUM (nn << bits_to_shift);
-            }
-          else
-            {
-              SCM result = scm_i_inum2big (nn);
-              mpz_mul_2exp (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (result),
-                            bits_to_shift);
-              return result;
-            }
-        }
+        return left_shift_exact_integer (n, bits_to_shift);
+      else if (SCM_LIKELY (bits_to_shift < 0))
+        return floor_right_shift_exact_integer (n, -bits_to_shift);
       else
-        {
-          bits_to_shift = -bits_to_shift;
-          if (bits_to_shift >= SCM_LONG_BIT)
-            return (nn >= 0 ? SCM_INUM0 : SCM_I_MAKINUM(-1));
-          else
-            return SCM_I_MAKINUM (SCM_SRS (nn, bits_to_shift));
-        }
-
+        return n;
     }
-  else if (SCM_BIGP (n))
-    {
-      SCM result;
+  else
+    SCM_WRONG_TYPE_ARG (SCM_ARG1, n);
+}
+#undef FUNC_NAME
 
-      if (bits_to_shift == 0)
-        return n;
+SCM_DEFINE (scm_round_ash, "round-ash", 2, 0, 0,
+            (SCM n, SCM count),
+           "Return @math{round(@var{n} * address@hidden)}.\n"
+           "@var{n} and @var{count} must be exact integers.\n"
+           "\n"
+           "With @var{n} viewed as an infinite-precision twos-complement\n"
+           "integer, @code{round-ash} means a left shift introducing zero\n"
+           "bits when @var{count} is positive, or a right shift rounding\n"
+           "to the nearest integer (with ties going to the nearest even\n"
+           "integer) when @var{count} is negative.  This is a rounded\n"
+           "``arithmetic'' shift.\n"
+           "\n"
+           "@lisp\n"
+           "(number->string (round-ash #b1 3) 2)     @result{} \"1000\"\n"
+           "(number->string (round-ash #b1010 -1) 2) @result{} \"101\"\n"
+           "(number->string (round-ash #b1010 -2) 2) @result{} \"10\"\n"
+           "(number->string (round-ash #b1011 -2) 2) @result{} \"11\"\n"
+           "(number->string (round-ash #b1101 -2) 2) @result{} \"11\"\n"
+           "(number->string (round-ash #b1110 -2) 2) @result{} \"100\"\n"
+           "@end lisp")
+#define FUNC_NAME s_scm_round_ash
+{
+  if (SCM_I_INUMP (n) || SCM_BIGP (n))
+    {
+      long bits_to_shift = scm_to_long (count);
 
-      result = scm_i_mkbig ();
-      if (bits_to_shift >= 0)
-        {
-          mpz_mul_2exp (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (n),
-                        bits_to_shift);
-          return result;
-        }
+      if (bits_to_shift > 0)
+        return left_shift_exact_integer (n, bits_to_shift);
+      else if (SCM_LIKELY (bits_to_shift < 0))
+        return round_right_shift_exact_integer (n, -bits_to_shift);
       else
-        {
-          /* GMP doesn't have an fdiv_q_2exp variant returning just a long, so
-             we have to allocate a bignum even if the result is going to be a
-             fixnum.  */
-          mpz_fdiv_q_2exp (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (n),
-                           -bits_to_shift);
-          return scm_i_normbig (result);
-        }
-
+        return n;
     }
   else
-    {
-      SCM_WRONG_TYPE_ARG (SCM_ARG1, n);
-    }
+    SCM_WRONG_TYPE_ARG (SCM_ARG1, n);
 }
 #undef FUNC_NAME
 
@@ -4998,220 +5289,230 @@ SCM_DEFINE (scm_integer_length, "integer-length", 1, 
0, 0,
 #undef FUNC_NAME
 
 /*** NUMBERS -> STRINGS ***/
-#define SCM_MAX_DBL_PREC  60
 #define SCM_MAX_DBL_RADIX 36
 
-/* this is an array starting with radix 2, and ending with radix 
SCM_MAX_DBL_RADIX */
-static int scm_dblprec[SCM_MAX_DBL_RADIX - 1];
-static double fx_per_radix[SCM_MAX_DBL_RADIX - 1][SCM_MAX_DBL_PREC];
-
-static
-void init_dblprec(int *prec, int radix) {
-   /* determine floating point precision by adding successively
-      smaller increments to 1.0 until it is considered == 1.0 */
-   double f = ((double)1.0)/radix;
-   double fsum = 1.0 + f;
-
-   *prec = 0;
-   while (fsum != 1.0)
-   {
-      if (++(*prec) > SCM_MAX_DBL_PREC)
-         fsum = 1.0;
-      else
-      {
-         f /= radix;
-         fsum = f + 1.0;
-      }
-   }
-   (*prec) -= 1;
-}
-
-static
-void init_fx_radix(double *fx_list, int radix)
-{
-  /* initialize a per-radix list of tolerances.  When added
-     to a number < 1.0, we can determine if we should raund
-     up and quit converting a number to a string. */
-   int i;
-   fx_list[0] = 0.0;
-   fx_list[1] = 0.5;
-   for( i = 2 ; i < SCM_MAX_DBL_PREC; ++i ) 
-     fx_list[i] = (fx_list[i-1] / radix);
-}
-
 /* use this array as a way to generate a single digit */
 static const char number_chars[] = "0123456789abcdefghijklmnopqrstuvwxyz";
 
+static mpz_t dbl_minimum_normal_mantissa;
+
 static size_t
-idbl2str (double f, char *a, int radix)
+idbl2str (double dbl, char *a, int radix)
 {
-   int efmt, dpt, d, i, wp;
-   double *fx;
-#ifdef DBL_MIN_10_EXP
-   double f_cpy;
-   int exp_cpy;
-#endif /* DBL_MIN_10_EXP */
-   size_t ch = 0;
-   int exp = 0;
-
-   if(radix < 2 || 
-      radix > SCM_MAX_DBL_RADIX)
-   {
-      /* revert to existing behavior */
-      radix = 10;
-   }
+  int ch = 0;
 
-   wp = scm_dblprec[radix-2];
-   fx = fx_per_radix[radix-2];
+  if (radix < 2 || radix > SCM_MAX_DBL_RADIX)
+    /* revert to existing behavior */
+    radix = 10;
 
-  if (f == 0.0)
+  if (isinf (dbl))
     {
-#ifdef HAVE_COPYSIGN
-      double sgn = copysign (1.0, f);
-
-      if (sgn < 0.0)
-       a[ch++] = '-';
-#endif
-      goto zero;       /*{a[0]='0'; a[1]='.'; a[2]='0'; return 3;} */
+      strcpy (a, (dbl > 0.0) ? "+inf.0" : "-inf.0");
+      return 6;
     }
-
-  if (isinf (f))
+  else if (dbl > 0.0)
+    ;
+  else if (dbl < 0.0)
     {
-      if (f < 0)
-       strcpy (a, "-inf.0");
-      else
-       strcpy (a, "+inf.0");
-      return ch+6;
+      dbl = -dbl;
+      a[ch++] = '-';
     }
-  else if (isnan (f))
+  else if (dbl == 0.0)
     {
-      strcpy (a, "+nan.0");
-      return ch+6;
+      if (!double_is_non_negative_zero (dbl))
+        a[ch++] = '-';
+      strcpy (a + ch, "0.0");
+      return ch + 3;
     }
-
-  if (f < 0.0)
+  else if (isnan (dbl))
     {
-      f = -f;
-      a[ch++] = '-';
+      strcpy (a, "+nan.0");
+      return 6;
     }
 
-#ifdef DBL_MIN_10_EXP  /* Prevent unnormalized values, as from 
-                         make-uniform-vector, from causing infinite loops. */
-  /* just do the checking...if it passes, we do the conversion for our
-     radix again below */
-  f_cpy = f;
-  exp_cpy = exp;
+  /* Algorithm taken from "Printing Floating-Point Numbers Quickly and
+     Accurately" by Robert G. Burger and R. Kent Dybvig */
+  {
+    int e, k;
+    mpz_t f, r, s, mplus, mminus, hi, digit;
+    int f_is_even, f_is_odd;
+    int expon;
+    int show_exp = 0;
+
+    mpz_inits (f, r, s, mplus, mminus, hi, digit, NULL);
+    mpz_set_d (f, ldexp (frexp (dbl, &e), DBL_MANT_DIG));
+    if (e < DBL_MIN_EXP)
+      {
+        mpz_tdiv_q_2exp (f, f, DBL_MIN_EXP - e);
+        e = DBL_MIN_EXP;
+      }
+    e -= DBL_MANT_DIG;
 
-  while (f_cpy < 1.0)
-    {
-      f_cpy *= 10.0;
-      if (exp_cpy-- < DBL_MIN_10_EXP)
-       {
-         a[ch++] = '#';
-         a[ch++] = '.';
-         a[ch++] = '#';
-         return ch;
-       }
-    }
-  while (f_cpy > 10.0)
-    {
-      f_cpy *= 0.10;
-      if (exp_cpy++ > DBL_MAX_10_EXP)
-       {
-         a[ch++] = '#';
-         a[ch++] = '.';
-         a[ch++] = '#';
-         return ch;
-       }
-    }
-#endif
+    f_is_even = !mpz_odd_p (f);
+    f_is_odd = !f_is_even;
 
-  while (f < 1.0)
-    {
-      f *= radix;
-      exp--;
-    }
-  while (f > radix)
-    {
-      f /= radix;
-      exp++;
-    }
+    /* Initialize r, s, mplus, and mminus according
+       to Table 1 from the paper. */
+    if (e < 0)
+      {
+        mpz_set_ui (mminus, 1);
+        if (mpz_cmp (f, dbl_minimum_normal_mantissa) != 0
+            || e == DBL_MIN_EXP - DBL_MANT_DIG)
+          {
+            mpz_set_ui (mplus, 1);
+            mpz_mul_2exp (r, f, 1);
+            mpz_mul_2exp (s, mminus, 1 - e);
+          }
+        else
+          {
+            mpz_set_ui (mplus, 2);
+            mpz_mul_2exp (r, f, 2);
+            mpz_mul_2exp (s, mminus, 2 - e);
+          }
+      }
+    else
+      {
+        mpz_set_ui (mminus, 1);
+        mpz_mul_2exp (mminus, mminus, e);
+        if (mpz_cmp (f, dbl_minimum_normal_mantissa) != 0)
+          {
+            mpz_set (mplus, mminus);
+            mpz_mul_2exp (r, f, 1 + e);
+            mpz_set_ui (s, 2);
+          }
+        else
+          {
+            mpz_mul_2exp (mplus, mminus, 1);
+            mpz_mul_2exp (r, f, 2 + e);
+            mpz_set_ui (s, 4);
+          }
+      }
 
-  if (f + fx[wp] >= radix)
-    {
-      f = 1.0;
-      exp++;
-    }
- zero:
-  efmt = (exp < -3) || (exp > wp + 2);
-  if (!efmt)
+    /* Find the smallest k such that:
+         (r + mplus) / s <  radix^k  (if f is even)
+         (r + mplus) / s <= radix^k  (if f is odd) */
     {
-      if (exp < 0)
-       {
-         a[ch++] = '0';
-         a[ch++] = '.';
-         dpt = exp;
-         while (++dpt)
-           a[ch++] = '0';
-       }
-      else
-       dpt = exp + 1;
+      /* IMPROVE-ME: Make an initial guess to speed this up */
+      mpz_add (hi, r, mplus);
+      k = 0;
+      while (mpz_cmp (hi, s) >= f_is_odd)
+        {
+          mpz_mul_ui (s, s, radix);
+          k++;
+        }
+      if (k == 0)
+        {
+          mpz_mul_ui (hi, hi, radix);
+          while (mpz_cmp (hi, s) < f_is_odd)
+            {
+              mpz_mul_ui (r, r, radix);
+              mpz_mul_ui (mplus, mplus, radix);
+              mpz_mul_ui (mminus, mminus, radix);
+              mpz_mul_ui (hi, hi, radix);
+              k--;
+            }
+        }
     }
-  else
-    dpt = 1;
 
-  do
-    {
-      d = f;
-      f -= d;
-      a[ch++] = number_chars[d];
-      if (f < fx[wp])
-       break;
-      if (f + fx[wp] >= 1.0)
-       {
-          a[ch - 1] = number_chars[d+1]; 
-         break;
-       }
-      f *= radix;
-      if (!(--dpt))
-       a[ch++] = '.';
-    }
-  while (wp--);
+    expon = k - 1;
+    if (k <= 0)
+      {
+        if (k <= -3)
+          {
+            /* Use scientific notation */
+            show_exp = 1;
+            k = 1;
+          }
+        else
+          {
+            int i;
 
-  if (dpt > 0)
-    {
-      if ((dpt > 4) && (exp > 6))
-       {
-         d = (a[0] == '-' ? 2 : 1);
-         for (i = ch++; i > d; i--)
-           a[i] = a[i - 1];
-         a[d] = '.';
-         efmt = 1;
-       }
-      else
-       {
-         while (--dpt)
-           a[ch++] = '0';
-         a[ch++] = '.';
-       }
-    }
-  if (a[ch - 1] == '.')
-    a[ch++] = '0';             /* trailing zero */
-  if (efmt && exp)
-    {
-      a[ch++] = 'e';
-      if (exp < 0)
-       {
-         exp = -exp;
-         a[ch++] = '-';
-       }
-      for (i = radix; i <= exp; i *= radix);
-      for (i /= radix; i; i /= radix)
-       {
-          a[ch++] = number_chars[exp / i];
-         exp %= i;
-       }
-    }
+            /* Print leading zeroes */
+            a[ch++] = '0';
+            a[ch++] = '.';
+            for (i = 0; i > k; i--)
+              a[ch++] = '0';
+          }
+      }
+
+    for (;;)
+      {
+        int end_1_p, end_2_p;
+        int d;
+
+        mpz_mul_ui (mplus, mplus, radix);
+        mpz_mul_ui (mminus, mminus, radix);
+        mpz_mul_ui (r, r, radix);
+        mpz_fdiv_qr (digit, r, r, s);
+        d = mpz_get_ui (digit);
+
+        mpz_add (hi, r, mplus);
+        end_1_p = (mpz_cmp (r, mminus) < f_is_even);
+        end_2_p = (mpz_cmp (s, hi) < f_is_even);
+        if (end_1_p || end_2_p)
+          {
+            mpz_mul_2exp (r, r, 1);
+            if (!end_2_p)
+              ;
+            else if (!end_1_p)
+              d++;
+            else if (mpz_cmp (r, s) >= !(d & 1))
+              d++;
+            a[ch++] = number_chars[d];
+            if (--k == 0)
+              a[ch++] = '.';
+            break;
+          }
+        else
+          {
+            a[ch++] = number_chars[d];
+            if (--k == 0)
+              a[ch++] = '.';
+          }
+      }
+
+    if (k > 0)
+      {
+        if (expon >= 7 && k >= 4 && expon >= k)
+          {
+            /* Here we would have to print more than three zeroes
+               followed by a decimal point and another zero.  It
+               makes more sense to use scientific notation. */
+
+            /* Adjust k to what it would have been if we had chosen
+               scientific notation from the beginning. */
+            k -= expon;
+
+            /* k will now be <= 0, with magnitude equal to the number of
+               digits that we printed which should now be put after the
+               decimal point. */
+
+            /* Insert a decimal point */
+            memmove (a + ch + k + 1, a + ch + k, -k);
+            a[ch + k] = '.';
+            ch++;
+
+            show_exp = 1;
+          }
+        else
+          {
+            for (; k > 0; k--)
+              a[ch++] = '0';
+            a[ch++] = '.';
+          }
+      }
+
+    if (k == 0)
+      a[ch++] = '0';
+
+    if (show_exp)
+      {
+        a[ch++] = 'e';
+        ch += scm_iint2str (expon, radix, a + ch);
+      }
+
+    mpz_clears (f, r, s, mplus, mminus, hi, digit, NULL);
+  }
   return ch;
 }
 
@@ -5695,7 +5996,7 @@ mem2decimal_from_point (SCM result, SCM mem,
                break;
            }
 
-         if (exponent > SCM_MAXEXP)
+         if (exponent > ((sign == 1) ? SCM_MAXEXP : SCM_MAXEXP + DBL_DIG + 1))
            {
              size_t exp_len = idx - start;
              SCM exp_string = scm_i_substring_copy (mem, start, start + 
exp_len);
@@ -5731,7 +6032,8 @@ mem2decimal_from_point (SCM result, SCM mem,
 
 static SCM
 mem2ureal (SCM mem, unsigned int *p_idx,
-          unsigned int radix, enum t_exactness forced_x)
+          unsigned int radix, enum t_exactness forced_x,
+           int allow_inf_or_nan)
 {
   unsigned int idx = *p_idx;
   SCM result;
@@ -5744,30 +6046,53 @@ mem2ureal (SCM mem, unsigned int *p_idx,
   if (idx == len)
     return SCM_BOOL_F;
 
-  if (idx+5 <= len && !scm_i_string_strcmp (mem, idx, "inf.0"))
-    {
-      *p_idx = idx+5;
-      return scm_inf ();
-    }
-
-  if (idx+4 < len && !scm_i_string_strcmp (mem, idx, "nan."))
-    {
-      /* Cobble up the fractional part.  We might want to set the
-        NaN's mantissa from it. */
-      idx += 4;
-      if (!scm_is_eq (mem2uinteger (mem, &idx, 10, &implicit_x), SCM_INUM0))
-        {
+  if (allow_inf_or_nan && forced_x != EXACT && idx+5 <= len)
+    switch (scm_i_string_ref (mem, idx))
+      {
+      case 'i': case 'I':
+        switch (scm_i_string_ref (mem, idx + 1))
+          {
+          case 'n': case 'N':
+            switch (scm_i_string_ref (mem, idx + 2))
+              {
+              case 'f': case 'F':
+                if (scm_i_string_ref (mem, idx + 3) == '.'
+                    && scm_i_string_ref (mem, idx + 4) == '0')
+                  {
+                    *p_idx = idx+5;
+                    return scm_inf ();
+                  }
+              }
+          }
+      case 'n': case 'N':
+        switch (scm_i_string_ref (mem, idx + 1))
+          {
+          case 'a': case 'A':
+            switch (scm_i_string_ref (mem, idx + 2))
+              {
+              case 'n': case 'N':
+                if (scm_i_string_ref (mem, idx + 3) == '.')
+                  {
+                    /* Cobble up the fractional part.  We might want to
+                       set the NaN's mantissa from it. */
+                    idx += 4;
+                    if (!scm_is_eq (mem2uinteger (mem, &idx, 10, &implicit_x),
+                                    SCM_INUM0))
+                      {
 #if SCM_ENABLE_DEPRECATED == 1
-          scm_c_issue_deprecation_warning
-            ("Non-zero suffixes to `+nan.' are deprecated.  Use `+nan.0'.");
+                        scm_c_issue_deprecation_warning
+                          ("Non-zero suffixes to `+nan.' are deprecated.  Use 
`+nan.0'.");
 #else
-          return SCM_BOOL_F;
+                        return SCM_BOOL_F;
 #endif
-        }
+                      }
           
-      *p_idx = idx;
-      return scm_nan ();
-    }
+                    *p_idx = idx;
+                    return scm_nan ();
+                  }
+              }
+          }
+      }
 
   if (scm_i_string_ref (mem, idx) == '.')
     {
@@ -5800,7 +6125,7 @@ mem2ureal (SCM mem, unsigned int *p_idx,
             return SCM_BOOL_F;
 
          divisor = mem2uinteger (mem, &idx, radix, &implicit_x);
-         if (scm_is_false (divisor))
+         if (scm_is_false (divisor) || scm_is_eq (divisor, SCM_INUM0))
            return SCM_BOOL_F;
 
          /* both are int/big here, I assume */
@@ -5876,7 +6201,7 @@ mem2complex (SCM mem, unsigned int idx,
   if (idx == len)
     return SCM_BOOL_F;
 
-  ureal = mem2ureal (mem, &idx, radix, forced_x);
+  ureal = mem2ureal (mem, &idx, radix, forced_x, sign != 0);
   if (scm_is_false (ureal))
     {
       /* input must be either +i or -i */
@@ -5945,9 +6270,9 @@ mem2complex (SCM mem, unsigned int idx,
                  sign = -1;
                }
              else
-               sign = 1;
+               sign = 0;
 
-             angle = mem2ureal (mem, &idx, radix, forced_x);
+             angle = mem2ureal (mem, &idx, radix, forced_x, sign != 0);
              if (scm_is_false (angle))
                return SCM_BOOL_F;
              if (idx != len)
@@ -5969,7 +6294,7 @@ mem2complex (SCM mem, unsigned int idx,
          else
            {
              int sign = (c == '+') ? 1 : -1;
-             SCM imag = mem2ureal (mem, &idx, radix, forced_x);
+             SCM imag = mem2ureal (mem, &idx, radix, forced_x, sign != 0);
 
              if (scm_is_false (imag))
                imag = SCM_I_MAKINUM (sign);
@@ -7323,8 +7648,9 @@ scm_difference (SCM x, SCM y)
           return scm_c_make_rectangular (-SCM_COMPLEX_REAL (x),
                                    -SCM_COMPLEX_IMAG (x));
        else if (SCM_FRACTIONP (x))
-         return scm_i_make_ratio (scm_difference (SCM_FRACTION_NUMERATOR (x), 
SCM_UNDEFINED),
-                                SCM_FRACTION_DENOMINATOR (x));
+         return scm_i_make_ratio_already_reduced
+           (scm_difference (SCM_FRACTION_NUMERATOR (x), SCM_UNDEFINED),
+            SCM_FRACTION_DENOMINATOR (x));
         else
           return scm_wta_dispatch_1 (g_difference, x, SCM_ARG1, s_difference);
     }
@@ -7850,8 +8176,8 @@ SCM_PRIMITIVE_GENERIC (scm_i_divide, "/", 0, 2, 1,
 #define s_divide s_scm_i_divide
 #define g_divide g_scm_i_divide
 
-static SCM
-do_divide (SCM x, SCM y, int inexact)
+SCM
+scm_divide (SCM x, SCM y)
 #define FUNC_NAME s_divide
 {
   double a;
@@ -7870,18 +8196,10 @@ do_divide (SCM x, SCM y, int inexact)
            scm_num_overflow (s_divide);
 #endif
          else
-           {
-             if (inexact)
-               return scm_from_double (1.0 / (double) xx);
-             else return scm_i_make_ratio (SCM_INUM1, x);
-           }
+           return scm_i_make_ratio_already_reduced (SCM_INUM1, x);
        }
       else if (SCM_BIGP (x))
-       {
-         if (inexact)
-           return scm_from_double (1.0 / scm_i_big2dbl (x));
-         else return scm_i_make_ratio (SCM_INUM1, x);
-       }
+       return scm_i_make_ratio_already_reduced (SCM_INUM1, x);
       else if (SCM_REALP (x))
        {
          double xx = SCM_REAL_VALUE (x);
@@ -7910,8 +8228,8 @@ do_divide (SCM x, SCM y, int inexact)
            }
        }
       else if (SCM_FRACTIONP (x))
-       return scm_i_make_ratio (SCM_FRACTION_DENOMINATOR (x),
-                              SCM_FRACTION_NUMERATOR (x));
+       return scm_i_make_ratio_already_reduced (SCM_FRACTION_DENOMINATOR (x),
+                                                SCM_FRACTION_NUMERATOR (x));
       else
        return scm_wta_dispatch_1 (g_divide, x, SCM_ARG1, s_divide);
     }
@@ -7931,11 +8249,7 @@ do_divide (SCM x, SCM y, int inexact)
 #endif
            }
          else if (xx % yy != 0)
-           {
-             if (inexact)
-               return scm_from_double ((double) xx / (double) yy);
-             else return scm_i_make_ratio (x, y);
-           }
+           return scm_i_make_ratio (x, y);
          else
            {
              scm_t_inum z = xx / yy;
@@ -7946,11 +8260,7 @@ do_divide (SCM x, SCM y, int inexact)
            }
        }
       else if (SCM_BIGP (y))
-       {
-         if (inexact)
-           return scm_from_double ((double) xx / scm_i_big2dbl (y));
-         else return scm_i_make_ratio (x, y);
-       }
+       return scm_i_make_ratio (x, y);
       else if (SCM_REALP (y))
        {
          double yy = SCM_REAL_VALUE (y);
@@ -7959,6 +8269,9 @@ do_divide (SCM x, SCM y, int inexact)
            scm_num_overflow (s_divide);
          else
 #endif
+            /* FIXME: Precision may be lost here due to:
+               (1) The cast from 'scm_t_inum' to 'double'
+               (2) Double rounding */
            return scm_from_double ((double) xx / yy);
        }
       else if (SCM_COMPLEXP (y))
@@ -7985,7 +8298,7 @@ do_divide (SCM x, SCM y, int inexact)
       else if (SCM_FRACTIONP (y))
        /* a / b/c = ac / b */
        return scm_i_make_ratio (scm_product (x, SCM_FRACTION_DENOMINATOR (y)),
-                              SCM_FRACTION_NUMERATOR (y));
+                                 SCM_FRACTION_NUMERATOR (y));
       else
        return scm_wta_dispatch_2 (g_divide, x, y, SCM_ARGn, s_divide);
     }
@@ -8029,43 +8342,24 @@ do_divide (SCM x, SCM y, int inexact)
                  return scm_i_normbig (result);
                }
              else
-               {
-                 if (inexact)
-                   return scm_from_double (scm_i_big2dbl (x) / (double) yy);
-                 else return scm_i_make_ratio (x, y);
-               }
+               return scm_i_make_ratio (x, y);
            }
        }
       else if (SCM_BIGP (y))
        {
-         /* big_x / big_y */
-         if (inexact)
-           {
-             /* It's easily possible for the ratio x/y to fit a double
-                but one or both x and y be too big to fit a double,
-                hence the use of mpq_get_d rather than converting and
-                dividing.  */
-             mpq_t q;
-             *mpq_numref(q) = *SCM_I_BIG_MPZ (x);
-             *mpq_denref(q) = *SCM_I_BIG_MPZ (y);
-             return scm_from_double (mpq_get_d (q));
-           }
-         else
-           {
-             int divisible_p = mpz_divisible_p (SCM_I_BIG_MPZ (x),
-                                                SCM_I_BIG_MPZ (y));
-             if (divisible_p)
-               {
-                 SCM result = scm_i_mkbig ();
-                 mpz_divexact (SCM_I_BIG_MPZ (result),
-                               SCM_I_BIG_MPZ (x),
-                               SCM_I_BIG_MPZ (y));
-                 scm_remember_upto_here_2 (x, y);
-                 return scm_i_normbig (result);
-               }
-             else
-               return scm_i_make_ratio (x, y);
-           }
+          int divisible_p = mpz_divisible_p (SCM_I_BIG_MPZ (x),
+                                             SCM_I_BIG_MPZ (y));
+          if (divisible_p)
+            {
+              SCM result = scm_i_mkbig ();
+              mpz_divexact (SCM_I_BIG_MPZ (result),
+                            SCM_I_BIG_MPZ (x),
+                            SCM_I_BIG_MPZ (y));
+              scm_remember_upto_here_2 (x, y);
+              return scm_i_normbig (result);
+            }
+          else
+            return scm_i_make_ratio (x, y);
        }
       else if (SCM_REALP (y))
        {
@@ -8075,6 +8369,8 @@ do_divide (SCM x, SCM y, int inexact)
            scm_num_overflow (s_divide);
          else
 #endif
+            /* FIXME: Precision may be lost here due to:
+               (1) scm_i_big2dbl (2) Double rounding */
            return scm_from_double (scm_i_big2dbl (x) / yy);
        }
       else if (SCM_COMPLEXP (y))
@@ -8084,7 +8380,7 @@ do_divide (SCM x, SCM y, int inexact)
        }
       else if (SCM_FRACTIONP (y))
        return scm_i_make_ratio (scm_product (x, SCM_FRACTION_DENOMINATOR (y)),
-                              SCM_FRACTION_NUMERATOR (y));
+                                 SCM_FRACTION_NUMERATOR (y));
       else
        return scm_wta_dispatch_2 (g_divide, x, y, SCM_ARGn, s_divide);
     }
@@ -8099,10 +8395,16 @@ do_divide (SCM x, SCM y, int inexact)
            scm_num_overflow (s_divide);
          else
 #endif
+            /* FIXME: Precision may be lost here due to:
+               (1) The cast from 'scm_t_inum' to 'double'
+               (2) Double rounding */
            return scm_from_double (rx / (double) yy);
        }
       else if (SCM_BIGP (y))
        {
+          /* FIXME: Precision may be lost here due to:
+             (1) The conversion from bignum to double
+             (2) Double rounding */
          double dby = mpz_get_d (SCM_I_BIG_MPZ (y));
          scm_remember_upto_here_1 (y);
          return scm_from_double (rx / dby);
@@ -8140,12 +8442,18 @@ do_divide (SCM x, SCM y, int inexact)
          else
 #endif
            {
+              /* FIXME: Precision may be lost here due to:
+                 (1) The conversion from 'scm_t_inum' to double
+                 (2) Double rounding */
              double d = yy;
              return scm_c_make_rectangular (rx / d, ix / d);
            }
        }
       else if (SCM_BIGP (y))
        {
+          /* FIXME: Precision may be lost here due to:
+             (1) The conversion from bignum to double
+             (2) Double rounding */
          double dby = mpz_get_d (SCM_I_BIG_MPZ (y));
          scm_remember_upto_here_1 (y);
          return scm_c_make_rectangular (rx / dby, ix / dby);
@@ -8179,6 +8487,9 @@ do_divide (SCM x, SCM y, int inexact)
        }
       else if (SCM_FRACTIONP (y))
        {
+          /* FIXME: Precision may be lost here due to:
+             (1) The conversion from fraction to double
+             (2) Double rounding */
          double yy = scm_i_fraction2double (y);
          return scm_c_make_rectangular (rx / yy, ix / yy);
        }
@@ -8196,12 +8507,12 @@ do_divide (SCM x, SCM y, int inexact)
          else
 #endif
            return scm_i_make_ratio (SCM_FRACTION_NUMERATOR (x),
-                                  scm_product (SCM_FRACTION_DENOMINATOR (x), 
y));
+                                     scm_product (SCM_FRACTION_DENOMINATOR 
(x), y));
        } 
       else if (SCM_BIGP (y)) 
        {
          return scm_i_make_ratio (SCM_FRACTION_NUMERATOR (x),
-                                scm_product (SCM_FRACTION_DENOMINATOR (x), y));
+                                   scm_product (SCM_FRACTION_DENOMINATOR (x), 
y));
        } 
       else if (SCM_REALP (y)) 
        {
@@ -8211,33 +8522,28 @@ do_divide (SCM x, SCM y, int inexact)
            scm_num_overflow (s_divide);
          else
 #endif
+            /* FIXME: Precision may be lost here due to:
+               (1) The conversion from fraction to double
+               (2) Double rounding */
            return scm_from_double (scm_i_fraction2double (x) / yy);
        }
       else if (SCM_COMPLEXP (y)) 
        {
+          /* FIXME: Precision may be lost here due to:
+             (1) The conversion from fraction to double
+             (2) Double rounding */
          a = scm_i_fraction2double (x);
          goto complex_div;
        } 
       else if (SCM_FRACTIONP (y))
        return scm_i_make_ratio (scm_product (SCM_FRACTION_NUMERATOR (x), 
SCM_FRACTION_DENOMINATOR (y)),
-                              scm_product (SCM_FRACTION_NUMERATOR (y), 
SCM_FRACTION_DENOMINATOR (x)));
+                                 scm_product (SCM_FRACTION_NUMERATOR (y), 
SCM_FRACTION_DENOMINATOR (x)));
       else 
        return scm_wta_dispatch_2 (g_divide, x, y, SCM_ARGn, s_divide);
     }
   else
     return scm_wta_dispatch_2 (g_divide, x, y, SCM_ARG1, s_divide);
 }
-
-SCM
-scm_divide (SCM x, SCM y)
-{
-  return do_divide (x, y, 0);
-}
-
-static SCM scm_divide2real (SCM x, SCM y)
-{
-  return do_divide (x, y, 1);
-}
 #undef FUNC_NAME
 
 
@@ -8875,8 +9181,9 @@ SCM_PRIMITIVE_GENERIC (scm_magnitude, "magnitude", 1, 0, 
0,
     {
       if (scm_is_false (scm_negative_p (SCM_FRACTION_NUMERATOR (z))))
        return z;
-      return scm_i_make_ratio (scm_difference (SCM_FRACTION_NUMERATOR (z), 
SCM_UNDEFINED),
-                            SCM_FRACTION_DENOMINATOR (z));
+      return scm_i_make_ratio_already_reduced
+       (scm_difference (SCM_FRACTION_NUMERATOR (z), SCM_UNDEFINED),
+        SCM_FRACTION_DENOMINATOR (z));
     }
   else
     return scm_wta_dispatch_1 (g_scm_magnitude, z, SCM_ARG1,
@@ -8973,21 +9280,35 @@ SCM_PRIMITIVE_GENERIC (scm_inexact_to_exact, 
"inexact->exact", 1, 0, 0,
 
       if (!SCM_LIKELY (DOUBLE_IS_FINITE (val)))
        SCM_OUT_OF_RANGE (1, z);
+      else if (val == 0.0)
+        return SCM_INUM0;
       else
        {
-         mpq_t frac;
-         SCM q;
-         
-         mpq_init (frac);
-         mpq_set_d (frac, val);
-         q = scm_i_make_ratio (scm_i_mpz2num (mpq_numref (frac)),
-                               scm_i_mpz2num (mpq_denref (frac)));
+          int expon;
+          SCM numerator;
 
-         /* When scm_i_make_ratio throws, we leak the memory allocated
-            for frac...
-          */
-         mpq_clear (frac);
-         return q;
+          numerator = scm_i_dbl2big (ldexp (frexp (val, &expon),
+                                            DBL_MANT_DIG));
+          expon -= DBL_MANT_DIG;
+          if (expon < 0)
+            {
+              int shift = mpz_scan1 (SCM_I_BIG_MPZ (numerator), 0);
+
+              if (shift > -expon)
+                shift = -expon;
+              mpz_fdiv_q_2exp (SCM_I_BIG_MPZ (numerator),
+                               SCM_I_BIG_MPZ (numerator),
+                               shift);
+              expon += shift;
+            }
+          numerator = scm_i_normbig (numerator);
+          if (expon < 0)
+            return scm_i_make_ratio_already_reduced
+              (numerator, left_shift_exact_integer (SCM_INUM1, -expon));
+          else if (expon > 0)
+            return left_shift_exact_integer (numerator, expon);
+          else
+            return numerator;
        }
     }
 }
@@ -9423,26 +9744,20 @@ log_of_shifted_double (double x, long shift)
     return scm_c_make_rectangular (ans, M_PI);
 }
 
-/* Returns log(n), for exact integer n of integer-length size */
-static SCM
-log_of_exact_integer_with_size (SCM n, long size)
-{
-  long shift = size - 2 * scm_dblprec[0];
-
-  if (shift > 0)
-    return log_of_shifted_double
-      (scm_to_double (scm_ash (n, scm_from_long(-shift))),
-       shift);
-  else
-    return log_of_shifted_double (scm_to_double (n), 0);
-}
-
 /* Returns log(n), for exact integer n */
 static SCM
 log_of_exact_integer (SCM n)
 {
-  return log_of_exact_integer_with_size
-    (n, scm_to_long (scm_integer_length (n)));
+  if (SCM_I_INUMP (n))
+    return log_of_shifted_double (SCM_I_INUM (n), 0);
+  else if (SCM_BIGP (n))
+    {
+      long expon;
+      double signif = scm_i_big2dbl_2exp (n, &expon);
+      return log_of_shifted_double (signif, expon);
+    }
+  else
+    scm_wrong_type_arg ("log_of_exact_integer", SCM_ARG1, n);
 }
 
 /* Returns log(n/d), for exact non-zero integers n and d */
@@ -9453,16 +9768,15 @@ log_of_fraction (SCM n, SCM d)
   long d_size = scm_to_long (scm_integer_length (d));
 
   if (abs (n_size - d_size) > 1)
-    return (scm_difference (log_of_exact_integer_with_size (n, n_size),
-                           log_of_exact_integer_with_size (d, d_size)));
+    return (scm_difference (log_of_exact_integer (n),
+                           log_of_exact_integer (d)));
   else if (scm_is_false (scm_negative_p (n)))
     return scm_from_double
-      (log1p (scm_to_double (scm_divide2real (scm_difference (n, d), d))));
+      (log1p (scm_i_divide2double (scm_difference (n, d), d)));
   else
     return scm_c_make_rectangular
-      (log1p (scm_to_double (scm_divide2real
-                            (scm_difference (scm_abs (n), d),
-                             d))),
+      (log1p (scm_i_divide2double (scm_difference (scm_abs (n), d),
+                                   d)),
        M_PI);
 }
 
@@ -9610,25 +9924,17 @@ scm_exact_integer_sqrt (SCM k, SCM *sp, SCM *rp)
 {
   if (SCM_LIKELY (SCM_I_INUMP (k)))
     {
-      scm_t_inum kk = SCM_I_INUM (k);
-      scm_t_inum uu = kk;
-      scm_t_inum ss;
+      mpz_t kk, ss, rr;
 
-      if (SCM_LIKELY (kk > 0))
-       {
-         do
-           {
-             ss = uu;
-             uu = (ss + kk/ss) / 2;
-           } while (uu < ss);
-         *sp = SCM_I_MAKINUM (ss);
-         *rp = SCM_I_MAKINUM (kk - ss*ss);
-       }
-      else if (SCM_LIKELY (kk == 0))
-       *sp = *rp = SCM_INUM0;
-      else
+      if (SCM_I_INUM (k) < 0)
        scm_wrong_type_arg_msg ("exact-integer-sqrt", SCM_ARG1, k,
                                "exact non-negative integer");
+      mpz_init_set_ui (kk, SCM_I_INUM (k));
+      mpz_inits (ss, rr, NULL);
+      mpz_sqrtrem (ss, rr, kk);
+      *sp = SCM_I_MAKINUM (mpz_get_ui (ss));
+      *rp = SCM_I_MAKINUM (mpz_get_ui (rr));
+      mpz_clears (kk, ss, rr, NULL);
     }
   else if (SCM_LIKELY (SCM_BIGP (k)))
     {
@@ -9649,6 +9955,56 @@ scm_exact_integer_sqrt (SCM k, SCM *sp, SCM *rp)
                            "exact non-negative integer");
 }
 
+/* Return true iff K is a perfect square.
+   K must be an exact integer. */
+static int
+exact_integer_is_perfect_square (SCM k)
+{
+  int result;
+
+  if (SCM_LIKELY (SCM_I_INUMP (k)))
+    {
+      mpz_t kk;
+
+      mpz_init_set_si (kk, SCM_I_INUM (k));
+      result = mpz_perfect_square_p (kk);
+      mpz_clear (kk);
+    }
+  else
+    {
+      result = mpz_perfect_square_p (SCM_I_BIG_MPZ (k));
+      scm_remember_upto_here_1 (k);
+    }
+  return result;
+}
+
+/* Return the floor of the square root of K.
+   K must be an exact integer. */
+static SCM
+exact_integer_floor_square_root (SCM k)
+{
+  if (SCM_LIKELY (SCM_I_INUMP (k)))
+    {
+      mpz_t kk;
+      scm_t_inum ss;
+
+      mpz_init_set_ui (kk, SCM_I_INUM (k));
+      mpz_sqrt (kk, kk);
+      ss = mpz_get_ui (kk);
+      mpz_clear (kk);
+      return SCM_I_MAKINUM (ss);
+    }
+  else
+    {
+      SCM s;
+
+      s = scm_i_mkbig ();
+      mpz_sqrt (SCM_I_BIG_MPZ (s), SCM_I_BIG_MPZ (k));
+      scm_remember_upto_here_1 (k);
+      return scm_i_normbig (s);
+    }
+}
+
 
 SCM_PRIMITIVE_GENERIC (scm_sqrt, "sqrt", 1, 0, 0,
                       (SCM z),
@@ -9679,11 +10035,111 @@ SCM_PRIMITIVE_GENERIC (scm_sqrt, "sqrt", 1, 0, 0,
     }
   else if (SCM_NUMBERP (z))
     {
-      double xx = scm_to_double (z);
-      if (xx < 0)
-        return scm_c_make_rectangular (0.0, sqrt (-xx));
-      else
-        return scm_from_double (sqrt (xx));
+      if (SCM_I_INUMP (z))
+        {
+          scm_t_inum x = SCM_I_INUM (z);
+
+          if (SCM_LIKELY (x >= 0))
+            {
+              if (SCM_LIKELY (SCM_I_FIXNUM_BIT < DBL_MANT_DIG
+                              || x < (1L << (DBL_MANT_DIG - 1))))
+                {
+                  double root = sqrt (x);
+
+                  /* If 0 <= x < 2^(DBL_MANT_DIG-1) and sqrt(x) is an
+                     integer, then the result is exact. */
+                  if (root == floor (root))
+                    return SCM_I_MAKINUM ((scm_t_inum) root);
+                  else
+                    return scm_from_double (root);
+                }
+              else
+                {
+                  mpz_t xx;
+                  scm_t_inum root;
+
+                  mpz_init_set_ui (xx, x);
+                  if (mpz_perfect_square_p (xx))
+                    {
+                      mpz_sqrt (xx, xx);
+                      root = mpz_get_ui (xx);
+                      mpz_clear (xx);
+                      return SCM_I_MAKINUM (root);
+                    }
+                  else
+                    mpz_clear (xx);
+                }
+            }
+        }
+      else if (SCM_BIGP (z))
+        {
+          if (mpz_perfect_square_p (SCM_I_BIG_MPZ (z)))
+            {
+              SCM root = scm_i_mkbig ();
+
+              mpz_sqrt (SCM_I_BIG_MPZ (root), SCM_I_BIG_MPZ (z));
+              scm_remember_upto_here_1 (z);
+              return scm_i_normbig (root);
+            }
+          else
+            {
+              long expon;
+              double signif = scm_i_big2dbl_2exp (z, &expon);
+
+              if (expon & 1)
+                {
+                  signif *= 2;
+                  expon--;
+                }
+              if (signif < 0)
+                return scm_c_make_rectangular
+                  (0.0, ldexp (sqrt (-signif), expon / 2));
+              else
+                return scm_from_double (ldexp (sqrt (signif), expon / 2));
+            }
+        }
+      else if (SCM_FRACTIONP (z))
+        {
+          SCM n = SCM_FRACTION_NUMERATOR (z);
+          SCM d = SCM_FRACTION_DENOMINATOR (z);
+
+          if (exact_integer_is_perfect_square (n)
+              && exact_integer_is_perfect_square (d))
+            return scm_i_make_ratio_already_reduced
+              (exact_integer_floor_square_root (n),
+               exact_integer_floor_square_root (d));
+          else
+            {
+              double xx = scm_i_divide2double (n, d);
+              double abs_xx = fabs (xx);
+              long shift = 0;
+
+              if (SCM_UNLIKELY (abs_xx > DBL_MAX || abs_xx < DBL_MIN))
+                {
+                  shift = (scm_to_long (scm_integer_length (n))
+                           - scm_to_long (scm_integer_length (d))) / 2;
+                  if (shift > 0)
+                    d = left_shift_exact_integer (d, 2 * shift);
+                  else
+                    n = left_shift_exact_integer (n, -2 * shift);
+                  xx = scm_i_divide2double (n, d);
+                }
+
+              if (xx < 0)
+                return scm_c_make_rectangular (0.0, ldexp (sqrt (-xx), shift));
+              else
+                return scm_from_double (ldexp (sqrt (xx), shift));
+            }
+        }
+
+      /* Fallback method, when the cases above do not apply. */
+      {
+        double xx = scm_to_double (z);
+        if (xx < 0)
+          return scm_c_make_rectangular (0.0, sqrt (-xx));
+        else
+          return scm_from_double (sqrt (xx));
+      }
     }
   else
     return scm_wta_dispatch_1 (g_scm_sqrt, z, 1, s_scm_sqrt);
@@ -9695,8 +10151,6 @@ SCM_PRIMITIVE_GENERIC (scm_sqrt, "sqrt", 1, 0, 0,
 void
 scm_init_numbers ()
 {
-  int i;
-
   if (scm_install_gmp_memory_functions)
     mp_set_memory_functions (custom_gmp_malloc,
                              custom_gmp_realloc,
@@ -9718,18 +10172,25 @@ scm_init_numbers ()
   flo0 = scm_from_double (0.0);
   flo_log10e = scm_from_double (M_LOG10E);
 
-  /* determine floating point precision */
-  for (i=2; i <= SCM_MAX_DBL_RADIX; ++i)
-    {
-      init_dblprec(&scm_dblprec[i-2],i);
-      init_fx_radix(fx_per_radix[i-2],i);
-    }
-#ifdef DBL_DIG
-  /* hard code precision for base 10 if the preprocessor tells us to... */
-  scm_dblprec[10-2] = (DBL_DIG > 20) ? 20 : DBL_DIG;
-#endif
-
   exactly_one_half = scm_divide (SCM_INUM1, SCM_I_MAKINUM (2));
+
+  {
+    /* Set scm_i_divide2double_lo2b to (2 b^p - 1) */
+    mpz_init_set_ui (scm_i_divide2double_lo2b, 1);
+    mpz_mul_2exp (scm_i_divide2double_lo2b,
+                  scm_i_divide2double_lo2b,
+                  DBL_MANT_DIG + 1); /* 2 b^p */
+    mpz_sub_ui (scm_i_divide2double_lo2b, scm_i_divide2double_lo2b, 1);
+  }
+
+  {
+    /* Set dbl_minimum_normal_mantissa to b^{p-1} */
+    mpz_init_set_ui (dbl_minimum_normal_mantissa, 1);
+    mpz_mul_2exp (dbl_minimum_normal_mantissa,
+                  dbl_minimum_normal_mantissa,
+                  DBL_MANT_DIG - 1);
+  }
+
 #include "libguile/numbers.x"
 }
 
diff --git a/libguile/numbers.h b/libguile/numbers.h
index cef2b86..01eb2cf 100644
--- a/libguile/numbers.h
+++ b/libguile/numbers.h
@@ -3,7 +3,8 @@
 #ifndef SCM_NUMBERS_H
 #define SCM_NUMBERS_H
 
-/* Copyright (C) 1995,1996,1998,2000,2001,2002,2003,2004,2005, 2006, 2008, 
2009, 2010, 2011 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1998,2000,2001,2002,2003,2004,2005, 2006,
+ *   2008, 2009, 2010, 2011, 2013 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -204,7 +205,8 @@ SCM_API SCM scm_logbit_p (SCM n1, SCM n2);
 SCM_API SCM scm_lognot (SCM n);
 SCM_API SCM scm_modulo_expt (SCM n, SCM k, SCM m);
 SCM_API SCM scm_integer_expt (SCM z1, SCM z2);
-SCM_API SCM scm_ash (SCM n, SCM cnt);
+SCM_API SCM scm_ash (SCM n, SCM count);
+SCM_API SCM scm_round_ash (SCM n, SCM count);
 SCM_API SCM scm_bit_extract (SCM n, SCM start, SCM end);
 SCM_API SCM scm_logcount (SCM n);
 SCM_API SCM scm_integer_length (SCM n);
@@ -500,6 +502,18 @@ SCM_API SCM  scm_from_mpz (mpz_t rop);
 #endif
 #endif
 
+#if SCM_SIZEOF_SCM_T_PTRDIFF == 4
+#define scm_to_ptrdiff_t    scm_to_int32
+#define scm_from_ptrdiff_t  scm_from_int32
+#else
+#if SCM_SIZEOF_SCM_T_PTRDIFF == 8
+#define scm_to_ptrdiff_t    scm_to_int64
+#define scm_from_ptrdiff_t  scm_from_int64
+#else
+#error sizeof(scm_t_ptrdiff) is not 4 or 8.
+#endif
+#endif
+
 /* conversion functions for double */
 
 SCM_API int scm_is_real (SCM val);
diff --git a/libguile/objcodes.c b/libguile/objcodes.c
index 0639028..4177c34 100644
--- a/libguile/objcodes.c
+++ b/libguile/objcodes.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 2001, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2009, 2010, 2011, 2012
+ *    2013 Free Software Foundation, Inc.
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -88,6 +89,8 @@
 #define ELFDATA ELFDATA2LSB
 #endif
 
+static void register_elf (char *data, size_t len);
+
 enum bytecode_kind
   {
     BYTECODE_KIND_NONE,
@@ -160,48 +163,104 @@ check_elf_header (const Elf_Ehdr *header)
   return NULL;
 }
 
-static int
-segment_flags_to_prot (Elf_Word flags)
+#define IS_ALIGNED(offset, alignment) \
+  (!((offset) & ((alignment) - 1)))
+#define ALIGN(offset, alignment) \
+  ((offset + (alignment - 1)) & ~(alignment - 1))
+
+static unsigned
+sniff_elf_alignment (const char *data, size_t len)
 {
-  int prot = 0;
-          
-  if (flags & PF_X)
-    prot |= PROT_EXEC;
-  if (flags & PF_W)
-    prot |= PROT_WRITE;
-  if (flags & PF_R)
-    prot |= PROT_READ;
+  Elf_Ehdr *header;
+  int i;
+  unsigned alignment = 8;
+
+  if (len < sizeof(Elf_Ehdr))
+    return alignment;
+  header = (Elf_Ehdr *) data;
+  if (header->e_phoff + header->e_phnum * header->e_phentsize >= len)
+    return alignment;
+  for (i = 0; i < header->e_phnum; i++)
+    {
+      Elf_Phdr *phdr;
+      const char *phdr_addr = data + header->e_phoff + i * header->e_phentsize;
 
-  return prot;
+      if (!IS_ALIGNED ((scm_t_uintptr) phdr_addr, alignof_type (Elf_Phdr)))
+        return alignment;
+      phdr = (Elf_Phdr *) phdr_addr;
+
+      if (phdr->p_align & (phdr->p_align - 1))
+        return alignment;
+
+      if (phdr->p_align > alignment)
+        alignment = phdr->p_align;
+    }
+
+  return alignment;
 }
 
-static int
-map_segments (int fd, char **base,
-              const Elf_Phdr *from, const Elf_Phdr *to)
+/* This function leaks the memory that it allocates.  */
+static char*
+alloc_aligned (size_t len, unsigned alignment)
 {
-  int prot = segment_flags_to_prot (from->p_flags);
   char *ret;
 
-  ret = mmap (*base + from->p_vaddr,
-              to->p_offset + to->p_filesz - from->p_offset,
-              prot, MAP_PRIVATE, fd, from->p_offset);
+  if (alignment == 8)
+    {
+      /* FIXME: Assert that we actually have an 8-byte-aligned malloc.  */
+      ret = malloc (len);
+    }
+#if defined(HAVE_SYS_MMAN_H) && defined(MMAP_ANONYMOUS)
+  else if (alignment == SCM_PAGE_SIZE)
+    {
+      ret = mmap (NULL, len, PROT_READ | PROT_WRITE, -1, 0);
+      if (ret == MAP_FAILED)
+        SCM_SYSERROR;
+    }
+#endif
+  else
+    {
+      if (len + alignment < len)
+        abort ();
 
-  if (ret == (char *) -1)
-    return 1;
+      ret = malloc (len + alignment - 1);
+      if (!ret)
+        abort ();
+      ret = (char *) ALIGN ((scm_t_uintptr) ret, alignment);
+    }
 
-  if (!*base)
-    *base = ret;
+  return ret;
+}
 
-  return 0;
+static char*
+copy_and_align_elf_data (const char *data, size_t len)
+{
+  unsigned alignment;
+  char *copy;
+
+  alignment = sniff_elf_alignment (data, len);
+  copy = alloc_aligned (len, alignment);
+  memcpy(copy, data, len);
+
+  return copy;
 }
 
+#ifdef HAVE_SYS_MMAN_H
 static int
-mprotect_segments (char *base, const Elf_Phdr *from, const Elf_Phdr *to)
+segment_flags_to_prot (Elf_Word flags)
 {
-  return mprotect (base + from->p_vaddr,
-                   to->p_vaddr + to->p_memsz - from->p_vaddr,
-                   segment_flags_to_prot (from->p_flags));
+  int prot = 0;
+
+  if (flags & PF_X)
+    prot |= PROT_EXEC;
+  if (flags & PF_W)
+    prot |= PROT_WRITE;
+  if (flags & PF_R)
+    prot |= PROT_READ;
+
+  return prot;
 }
+#endif
 
 static char*
 process_dynamic_segment (char *base, Elf_Phdr *dyn_phdr,
@@ -299,152 +358,38 @@ process_dynamic_segment (char *base, Elf_Phdr *dyn_phdr,
 
 #define ABORT(msg) do { err_msg = msg; goto cleanup; } while (0)
 
-#ifdef HAVE_SYS_MMAN_H
 static SCM
-load_thunk_from_fd_using_mmap (int fd)
-#define FUNC_NAME "load-thunk-from-disk"
+load_thunk_from_memory (char *data, size_t len, int is_read_only)
+#define FUNC_NAME "load-thunk-from-memory"
 {
-  Elf_Ehdr header;
+  Elf_Ehdr *header;
   Elf_Phdr *ph;
   const char *err_msg = 0;
-  char *base = 0;
-  size_t n;
+  size_t n, alignment = 8;
   int i;
-  int start_segment = -1;
-  int prev_segment = -1;
   int dynamic_segment = -1;
   SCM init = SCM_BOOL_F, entry = SCM_BOOL_F;
 
-  if (full_read (fd, &header, sizeof header) != sizeof header)
+  if (len < sizeof *header)
     ABORT ("object file too small");
 
-  if ((err_msg = check_elf_header (&header)))
-    goto cleanup;
-
-  if (lseek (fd, header.e_phoff, SEEK_SET) == (off_t) -1)
-    goto cleanup;
+  header = (Elf_Ehdr*) data;
   
-  n = header.e_phnum;
-  ph = scm_gc_malloc_pointerless (n * sizeof (Elf_Phdr), "segment headers");
-
-  if (full_read (fd, ph, n * sizeof (Elf_Phdr)) != n * sizeof (Elf_Phdr))
-    ABORT ("failed to read program headers");
-      
-  for (i = 0; i < n; i++)
-    {
-      if (!ph[i].p_memsz)
-        continue;
-
-      if (ph[i].p_filesz != ph[i].p_memsz)
-        ABORT ("expected p_filesz == p_memsz");
-      
-      if (!ph[i].p_flags)
-        ABORT ("expected nonzero segment flags");
-
-      if (ph[i].p_type == PT_DYNAMIC)
-        {
-          if (dynamic_segment >= 0)
-            ABORT ("expected only one PT_DYNAMIC segment");
-          dynamic_segment = i;
-        }
-
-      if (start_segment < 0)
-        {
-          if (!base && ph[i].p_vaddr)
-            ABORT ("first loadable vaddr is not 0");
-            
-          start_segment = prev_segment = i;
-          continue;
-        }
-
-      if (ph[i].p_flags == ph[start_segment].p_flags)
-        {
-          if (ph[i].p_vaddr - ph[prev_segment].p_vaddr 
-              != ph[i].p_offset - ph[prev_segment].p_offset)
-            ABORT ("coalesced segments not contiguous");
-
-          prev_segment = i;
-          continue;
-        }
-
-      /* Otherwise we have a new kind of segment.  Map previous
-         segments.  */
-      if (map_segments (fd, &base, &ph[start_segment], &ph[prev_segment]))
-        goto cleanup;
-
-      /* Open a new set of segments.  */
-      start_segment = prev_segment = i;
-    }
-
-  /* Map last segments.  */
-  if (start_segment < 0)
-    ABORT ("no loadable segments");
-
-  if (map_segments (fd, &base, &ph[start_segment], &ph[prev_segment]))
+  if ((err_msg = check_elf_header (header)))
     goto cleanup;
 
-  if (dynamic_segment < 0)
-    ABORT ("no PT_DYNAMIC segment");
-
-  if ((err_msg = process_dynamic_segment (base, &ph[dynamic_segment],
-                                          &init, &entry)))
-    goto cleanup;
-
-  if (scm_is_true (init))
-    scm_call_0 (init);
-
-  /* Finally!  Return the thunk.  */
-  return entry;
-
-  /* FIXME: munmap on error? */
- cleanup:
-  {
-    int errno_save = errno;
-    (void) close (fd);
-    errno = errno_save;
-    if (errno)
-      SCM_SYSERROR;
-    scm_misc_error (FUNC_NAME, err_msg ? err_msg : "error loading ELF file",
-                    SCM_EOL);
-  }
-}
-#undef FUNC_NAME
-#endif /* HAVE_SYS_MMAN_H */
-
-static SCM
-load_thunk_from_memory (char *data, size_t len)
-#define FUNC_NAME "load-thunk-from-memory"
-{
-  Elf_Ehdr header;
-  Elf_Phdr *ph;
-  const char *err_msg = 0;
-  char *base = 0;
-  size_t n, memsz = 0, alignment = 8;
-  int i;
-  int first_loadable = -1;
-  int start_segment = -1;
-  int prev_segment = -1;
-  int dynamic_segment = -1;
-  SCM init = SCM_BOOL_F, entry = SCM_BOOL_F;
+  if (header->e_phnum == 0)
+    ABORT ("no loadable segments");
+  n = header->e_phnum;
 
-  if (len < sizeof header)
+  if (len < header->e_phoff + n * sizeof (Elf_Phdr))
     ABORT ("object file too small");
 
-  memcpy (&header, data, sizeof header);
-
-  if ((err_msg = check_elf_header (&header)))
-    goto cleanup;
-
-  n = header.e_phnum;
-  if (len < header.e_phoff + n * sizeof (Elf_Phdr))
-    goto cleanup;
-  ph = (Elf_Phdr*) (data + header.e_phoff);
+  ph = (Elf_Phdr*) (data + header->e_phoff);
 
+  /* Check that the segment table is sane.  */
   for (i = 0; i < n; i++)
     {
-      if (!ph[i].p_memsz)
-        continue;
-
       if (ph[i].p_filesz != ph[i].p_memsz)
         ABORT ("expected p_filesz == p_memsz");
 
@@ -465,90 +410,57 @@ load_thunk_from_memory (char *data, size_t len)
           dynamic_segment = i;
         }
 
-      if (first_loadable < 0)
+      if (i == 0)
         {
-          if (ph[i].p_vaddr)
+          if (ph[i].p_vaddr != 0)
             ABORT ("first loadable vaddr is not 0");
-
-          first_loadable = i;
         }
+      else
+        {
+          if (ph[i].p_vaddr < ph[i-1].p_vaddr + ph[i-1].p_memsz)
+            ABORT ("overlapping segments");
 
-      if (ph[i].p_vaddr < memsz)
-        ABORT ("overlapping segments");
-
-      if (ph[i].p_offset + ph[i].p_filesz > len)
-        ABORT ("segment beyond end of byte array");
-
-      memsz = ph[i].p_vaddr + ph[i].p_memsz;
+          if (ph[i].p_offset + ph[i].p_filesz > len)
+            ABORT ("segment beyond end of byte array");
+        }
     }
 
-  if (first_loadable < 0)
-    ABORT ("no loadable segments");
-
   if (dynamic_segment < 0)
     ABORT ("no PT_DYNAMIC segment");
 
-  /* Now copy segments.  */
-
-  /* We leak this memory, as we leak the memory mappings in
-     load_thunk_from_fd_using_mmap.
+  if (!IS_ALIGNED ((scm_t_uintptr) data, alignment))
+    ABORT ("incorrectly aligned base");
 
-     If the file is has an alignment of 8, use the standard malloc.
-     (FIXME to ensure alignment on non-GNU malloc.)  Otherwise use
-     posix_memalign.  We only use mprotect if the aligment is 4096.  */
-  if (alignment == 8)
+  /* Allow writes to writable pages.  */
+  if (is_read_only)
     {
-      base = malloc (memsz);
-      if (!base)
-        goto cleanup;
-    }
-  else
-    if ((errno = posix_memalign ((void **) &base, alignment, memsz)))
-      goto cleanup;
-
-  memset (base, 0, memsz);
-
-  for (i = 0; i < n; i++)
-    {
-      if (!ph[i].p_memsz)
-        continue;
-
-      memcpy (base + ph[i].p_vaddr,
-              data + ph[i].p_offset,
-              ph[i].p_memsz);
-
-      if (start_segment < 0)
-        {
-          start_segment = prev_segment = i;
-          continue;
-        }
-
-      if (ph[i].p_flags == ph[start_segment].p_flags)
+#ifdef HAVE_SYS_MMAN_H
+      for (i = 0; i < n; i++)
         {
-          prev_segment = i;
-          continue;
+          if (ph[i].p_flags == PF_R)
+            continue;
+          if (ph[i].p_align != 4096)
+            continue;
+
+          if (mprotect (data + ph[i].p_vaddr,
+                        ph[i].p_memsz,
+                        segment_flags_to_prot (ph[i].p_flags)))
+            goto cleanup;
         }
-
-      if (alignment == 4096)
-        if (mprotect_segments (base, &ph[start_segment], &ph[prev_segment]))
-          goto cleanup;
-
-      /* Open a new set of segments.  */
-      start_segment = prev_segment = i;
+#else
+      ABORT ("expected writable pages");
+#endif
     }
 
-  /* Mprotect the last segments.  */
-  if (alignment == 4096)
-    if (mprotect_segments (base, &ph[start_segment], &ph[prev_segment]))
-      goto cleanup;
-
-  if ((err_msg = process_dynamic_segment (base, &ph[dynamic_segment],
+  if ((err_msg = process_dynamic_segment (data, &ph[dynamic_segment],
                                           &init, &entry)))
     goto cleanup;
 
   if (scm_is_true (init))
     scm_call_0 (init);
 
+  register_elf (data, len);
+
   /* Finally!  Return the thunk.  */
   return entry;
 
@@ -562,22 +474,40 @@ load_thunk_from_memory (char *data, size_t len)
 }
 #undef FUNC_NAME
 
-#ifndef HAVE_SYS_MMAN_H
-static SCM
-load_thunk_from_fd_using_read (int fd)
-#define FUNC_NAME "load-thunk-from-disk"
+#define SCM_PAGE_SIZE 4096
+
+static char*
+map_file_contents (int fd, size_t len, int *is_read_only)
+#define FUNC_NAME "load-thunk-from-file"
 {
   char *data;
-  size_t len;
-  struct stat st;
-  int ret;
 
-  ret = fstat (fd, &st);
-  if (ret < 0)
+#ifdef HAVE_SYS_MMAN_H
+  data = mmap (NULL, len, PROT_READ, MAP_PRIVATE, fd, 0);
+  if (data == MAP_FAILED)
     SCM_SYSERROR;
-  len = st.st_size;
-  data = scm_gc_malloc_pointerless (len, "objcode");
-  if (full_read (fd, data, len) != len)
+  *is_read_only = 1;
+#else
+  if (lseek (fd, 0, SEEK_START) < 0)
+    {
+      int errno_save = errno;
+      (void) close (fd);
+      errno = errno_save;
+      SCM_SYSERROR;
+    }
+
+  /* Given that we are using the read fallback, optimistically assume
+     that the .go files were made with 8-byte alignment.
+     alignment.  */
+  data = malloc (end);
+  if (!data)
+    {
+      (void) close (fd);
+      scm_misc_error (FUNC_NAME, "failed to allocate ~A bytes",
+                      scm_list_1 (scm_from_size_t (end)));
+    }
+
+  if (full_read (fd, data, end) != end)
     {
       int errno_save = errno;
       (void) close (fd);
@@ -587,11 +517,25 @@ load_thunk_from_fd_using_read (int fd)
       scm_misc_error (FUNC_NAME, "short read while loading objcode",
                       SCM_EOL);
     }
-  (void) close (fd);
-  return load_thunk_from_memory (data, len);
+
+  /* If our optimism failed, fall back.  */
+  {
+    unsigned alignment = sniff_elf_alignment (data, end);
+
+    if (alignment != 8)
+      {
+        char *copy = copy_and_align_elf_data (data, end, alignment);
+        free (data);
+        data = copy;
+      }
+  }
+
+  *is_read_only = 0;
+#endif
+
+  return data;
 }
 #undef FUNC_NAME
-#endif /* ! HAVE_SYS_MMAN_H */
 
 SCM_DEFINE (scm_load_thunk_from_file, "load-thunk-from-file", 1, 0, 0,
            (SCM filename),
@@ -599,20 +543,26 @@ SCM_DEFINE (scm_load_thunk_from_file, 
"load-thunk-from-file", 1, 0, 0,
 #define FUNC_NAME s_scm_load_thunk_from_file
 {
   char *c_filename;
-  int fd;
+  int fd, is_read_only;
+  off_t end;
+  char *data;
 
   SCM_VALIDATE_STRING (1, filename);
 
   c_filename = scm_to_locale_string (filename);
-  fd = open (c_filename, O_RDONLY | O_CLOEXEC);
+  fd = open (c_filename, O_RDONLY | O_BINARY | O_CLOEXEC);
   free (c_filename);
   if (fd < 0) SCM_SYSERROR;
 
-#ifdef HAVE_SYS_MMAN_H
-  return load_thunk_from_fd_using_mmap (fd);
-#else
-  return load_thunk_from_fd_using_read (fd);
-#endif
+  end = lseek (fd, 0, SEEK_END);
+  if (end < 0)
+    SCM_SYSERROR;
+
+  data = map_file_contents (fd, end, &is_read_only);
+
+  (void) close (fd);
+
+  return load_thunk_from_memory (data, end, is_read_only);
 }
 #undef FUNC_NAME
 
@@ -621,10 +571,20 @@ SCM_DEFINE (scm_load_thunk_from_memory, 
"load-thunk-from-memory", 1, 0, 0,
            "")
 #define FUNC_NAME s_scm_load_thunk_from_memory
 {
+  char *data;
+  size_t len;
+
   SCM_VALIDATE_BYTEVECTOR (1, bv);
 
-  return load_thunk_from_memory ((char *) SCM_BYTEVECTOR_CONTENTS (bv),
-                                 SCM_BYTEVECTOR_LENGTH (bv));
+  data = (char *) SCM_BYTEVECTOR_CONTENTS (bv);
+  len = SCM_BYTEVECTOR_LENGTH (bv);
+
+  /* Copy data in order to align it, to trace its GC roots and
+     writable sections, and to keep it in memory.  */
+
+  data = copy_and_align_elf_data (data, len);
+
+  return load_thunk_from_memory (data, len, 0);
 }
 #undef FUNC_NAME
 
@@ -679,6 +639,107 @@ scm_c_make_objcode_slice (SCM parent, const scm_t_uint8 
*ptr)
 }
 #undef FUNC_NAME
 
+struct mapped_elf_image
+{
+  char *start;
+  char *end;
+};
+
+static struct mapped_elf_image *mapped_elf_images = NULL;
+static size_t mapped_elf_images_count = 0;
+static size_t mapped_elf_images_allocated = 0;
+
+static size_t
+find_mapped_elf_insertion_index (char *ptr)
+{
+  /* "mapped_elf_images_count" must never be dereferenced.  */
+  size_t start = 0, end = mapped_elf_images_count;
+
+  while (start < end)
+    {
+      size_t n = start + (end - start) / 2;
+
+      if (ptr < mapped_elf_images[n].end)
+        end = n;
+      else
+        start = n + 1;
+    }
+
+  return start;
+}
+
+static void
+register_elf (char *data, size_t len)
+{
+  scm_i_pthread_mutex_lock (&scm_i_misc_mutex);
+  {
+    /* My kingdom for a generic growable sorted vector library.  */
+    if (mapped_elf_images_count == mapped_elf_images_allocated)
+      {
+        struct mapped_elf_image *prev;
+        size_t n;
+
+        if (mapped_elf_images_allocated)
+          mapped_elf_images_allocated *= 2;
+        else
+          mapped_elf_images_allocated = 16;
+
+        prev = mapped_elf_images;
+        mapped_elf_images =
+          scm_gc_malloc_pointerless (sizeof (*mapped_elf_images)
+                                     * mapped_elf_images_allocated,
+                                     "mapped elf images");
+
+        for (n = 0; n < mapped_elf_images_count; n++)
+          {
+            mapped_elf_images[n].start = prev[n].start;
+            mapped_elf_images[n].end = prev[n].end;
+          }
+      }
+
+    {
+      size_t end;
+      size_t n = find_mapped_elf_insertion_index (data);
+
+      for (end = mapped_elf_images_count; n < end; end--)
+        {
+          mapped_elf_images[end].start = mapped_elf_images[end - 1].start;
+          mapped_elf_images[end].end = mapped_elf_images[end - 1].end;
+        }
+      mapped_elf_images_count++;
+
+      mapped_elf_images[n].start = data;
+      mapped_elf_images[n].end = data + len;
+    }
+  }
+  scm_i_pthread_mutex_unlock (&scm_i_misc_mutex);
+}
+
+static SCM
+scm_find_mapped_elf_image (SCM ip)
+{
+  char *ptr = (char *) scm_to_unsigned_integer (ip, 0, SCM_T_UINTPTR_MAX);
+  SCM result;
+
+  scm_i_pthread_mutex_lock (&scm_i_misc_mutex);
+  {
+    size_t n = find_mapped_elf_insertion_index ((char *) ptr);
+    if (n < mapped_elf_images_count
+        && mapped_elf_images[n].start <= ptr
+        && ptr < mapped_elf_images[n].end)
+      {
+        signed char *data = (signed char *) mapped_elf_images[n].start;
+        size_t len = mapped_elf_images[n].end - mapped_elf_images[n].start;
+        result = scm_c_take_gc_bytevector (data, len, SCM_BOOL_F);
+      }
+    else
+      result = SCM_BOOL_F;
+  }
+  scm_i_pthread_mutex_unlock (&scm_i_misc_mutex);
+
+  return result;
+}
+
 
 /*
  * Scheme interface
@@ -817,6 +878,9 @@ scm_init_objcodes (void)
 #include "libguile/objcodes.x"
 #endif
 
+  scm_c_define_gsubr ("find-mapped-elf-image", 1, 0, 0,
+                      (scm_t_subr) scm_find_mapped_elf_image);
+
   scm_c_define ("word-size", scm_from_size_t (sizeof(SCM)));
   scm_c_define ("byte-order", scm_from_uint16 (SCM_BYTE_ORDER));
 }
diff --git a/libguile/poll.c b/libguile/poll.c
index 1bb7572..9ea846b 100644
--- a/libguile/poll.c
+++ b/libguile/poll.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2010 Free Software Foundation, Inc.
+/* Copyright (C) 2010, 2013 Free Software Foundation, Inc.
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -25,6 +25,8 @@
 #  include <config.h>
 #endif
 
+#include <poll.h>
+
 #include "libguile/_scm.h"
 #include "libguile/bytevectors.h"
 #include "libguile/numbers.h"
@@ -34,11 +36,6 @@
 #include "libguile/poll.h"
 
 
-#ifdef HAVE_POLL_H
-#include <poll.h>
-#endif
-
-
 
 /* {Poll}
  */
@@ -73,7 +70,6 @@
    If timeout is given and is non-negative, the poll will return after that
    number of milliseconds if no fd became active.
    */
-#ifdef HAVE_POLL
 static SCM
 scm_primitive_poll (SCM pollfds, SCM nfds, SCM ports, SCM timeout)
 #define FUNC_NAME "primitive-poll"
@@ -174,7 +170,6 @@ scm_primitive_poll (SCM pollfds, SCM nfds, SCM ports, SCM 
timeout)
   return scm_from_int (rv);
 }
 #undef FUNC_NAME
-#endif /* HAVE_POLL */
 
 
 
@@ -182,12 +177,8 @@ scm_primitive_poll (SCM pollfds, SCM nfds, SCM ports, SCM 
timeout)
 static void
 scm_init_poll (void)
 {
-#if HAVE_POLL
   scm_c_define_gsubr ("primitive-poll", 4, 0, 0, scm_primitive_poll);
   scm_c_define ("%sizeof-struct-pollfd", scm_from_size_t (sizeof (struct 
pollfd)));
-#else
-  scm_misc_error ("%init-poll", "`poll' unavailable on this platform", 
SCM_EOL);
-#endif
 
 #ifdef POLLIN
   scm_c_define ("POLLIN", scm_from_int (POLLIN));
diff --git a/libguile/ports-internal.h b/libguile/ports-internal.h
new file mode 100644
index 0000000..bff89cb
--- /dev/null
+++ b/libguile/ports-internal.h
@@ -0,0 +1,66 @@
+/*
+ * ports-internal.h - internal-only declarations for ports.
+ *
+ * Copyright (C) 2013 Free Software Foundation, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 3 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef SCM_PORTS_INTERNAL
+#define SCM_PORTS_INTERNAL
+
+#include "libguile/_scm.h"
+#include "libguile/ports.h"
+
+enum scm_port_encoding_mode {
+  SCM_PORT_ENCODING_MODE_UTF8,
+  SCM_PORT_ENCODING_MODE_LATIN1,
+  SCM_PORT_ENCODING_MODE_ICONV
+};
+
+typedef enum scm_port_encoding_mode scm_t_port_encoding_mode;
+
+/* This is a separate object so that only those ports that use iconv
+   cause finalizers to be registered.  */
+struct scm_iconv_descriptors
+{
+  /* input/output iconv conversion descriptors */
+  void *input_cd;
+  void *output_cd;
+};
+
+typedef struct scm_iconv_descriptors scm_t_iconv_descriptors;
+
+struct scm_port_internal
+{
+  unsigned at_stream_start_for_bom_read  : 1;
+  unsigned at_stream_start_for_bom_write : 1;
+  scm_t_port_encoding_mode encoding_mode;
+  scm_t_iconv_descriptors *iconv_descriptors;
+  int pending_eof;
+  SCM alist;
+};
+
+typedef struct scm_port_internal scm_t_port_internal;
+
+#define SCM_UNICODE_BOM  0xFEFFUL  /* Unicode byte-order mark */
+
+#define SCM_PORT_GET_INTERNAL(x)  (SCM_PTAB_ENTRY(x)->internal)
+
+SCM_INTERNAL scm_t_iconv_descriptors *
+scm_i_port_iconv_descriptors (SCM port, scm_t_port_rw_active mode);
+
+#endif
diff --git a/libguile/ports.c b/libguile/ports.c
index 0aacacc..20c9081 100644
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@ -55,6 +55,7 @@
 #include "libguile/mallocs.h"
 #include "libguile/validate.h"
 #include "libguile/ports.h"
+#include "libguile/ports-internal.h"
 #include "libguile/vectors.h"
 #include "libguile/weak-set.h"
 #include "libguile/fluids.h"
@@ -329,6 +330,30 @@ scm_set_port_input_waiting (scm_t_bits tc, int 
(*input_waiting) (SCM))
   scm_c_port_type_ref (SCM_TC2PTOBNUM (tc))->input_waiting = input_waiting;
 }
 
+static void
+scm_i_set_pending_eof (SCM port)
+{
+  SCM_PORT_GET_INTERNAL (port)->pending_eof = 1;
+}
+
+static void
+scm_i_clear_pending_eof (SCM port)
+{
+  SCM_PORT_GET_INTERNAL (port)->pending_eof = 0;
+}
+
+SCM
+scm_i_port_alist (SCM port)
+{
+  return SCM_PORT_GET_INTERNAL (port)->alist;
+}
+
+void
+scm_i_set_port_alist_x (SCM port, SCM alist)
+{
+  SCM_PORT_GET_INTERNAL (port)->alist = alist;
+}
+
 
 
 /* Standard ports --- current input, output, error, and more(!).  */
@@ -383,10 +408,14 @@ SCM_DEFINE (scm_current_error_port, "current-error-port", 
0, 0, 0,
 SCM
 scm_current_warning_port (void)
 {
-  static SCM cwp_var = SCM_BOOL_F;
+  static SCM cwp_var = SCM_UNDEFINED;
+  static scm_i_pthread_mutex_t cwp_var_mutex
+    = SCM_I_PTHREAD_MUTEX_INITIALIZER;
 
-  if (scm_is_false (cwp_var))
-    cwp_var = scm_c_private_lookup ("guile", "current-warning-port");
+  scm_i_scm_pthread_mutex_lock (&cwp_var_mutex);
+  if (SCM_UNBNDP (cwp_var))
+    cwp_var = scm_c_private_variable ("guile", "current-warning-port");
+  scm_i_pthread_mutex_unlock (&cwp_var_mutex);
   
   return scm_call_0 (scm_variable_ref (cwp_var));
 }
@@ -637,9 +666,11 @@ scm_c_make_port_with_encoding (scm_t_bits tag, unsigned 
long mode_bits,
 {
   SCM ret;
   scm_t_port *entry;
+  scm_t_port_internal *pti;
   scm_t_ptob_descriptor *ptob;
 
-  entry = (scm_t_port *) scm_gc_calloc (sizeof (scm_t_port), "port");
+  entry = scm_gc_typed_calloc (scm_t_port);
+  pti = scm_gc_typed_calloc (scm_t_port_internal);
   ptob = scm_c_port_type_ref (SCM_TC2PTOBNUM (tag));
 
   ret = scm_words (tag | mode_bits, 3);
@@ -649,6 +680,7 @@ scm_c_make_port_with_encoding (scm_t_bits tag, unsigned 
long mode_bits,
   entry->lock = scm_gc_malloc_pointerless (sizeof (*entry->lock), "port lock");
   scm_i_pthread_mutex_init (entry->lock, scm_i_pthread_mutexattr_recursive);
 
+  entry->internal = pti;
   entry->file_name = SCM_BOOL_F;
   entry->rw_active = SCM_PORT_NEITHER;
   entry->port = ret;
@@ -656,24 +688,28 @@ scm_c_make_port_with_encoding (scm_t_bits tag, unsigned 
long mode_bits,
 
   if (encoding_matches (encoding, "UTF-8"))
     {
-      entry->encoding_mode = SCM_PORT_ENCODING_MODE_UTF8;
+      pti->encoding_mode = SCM_PORT_ENCODING_MODE_UTF8;
       entry->encoding = "UTF-8";
     }
   else if (encoding_matches (encoding, "ISO-8859-1"))
     {
-      entry->encoding_mode = SCM_PORT_ENCODING_MODE_LATIN1;
+      pti->encoding_mode = SCM_PORT_ENCODING_MODE_LATIN1;
       entry->encoding = "ISO-8859-1";
     }
   else
     {
-      entry->encoding_mode = SCM_PORT_ENCODING_MODE_ICONV;
+      pti->encoding_mode = SCM_PORT_ENCODING_MODE_ICONV;
       entry->encoding = canonicalize_encoding (encoding);
     }
 
   entry->ilseq_handler = handler;
-  entry->iconv_descriptors = NULL;
+  pti->iconv_descriptors = NULL;
+
+  pti->at_stream_start_for_bom_read  = 1;
+  pti->at_stream_start_for_bom_write = 1;
 
-  entry->alist = SCM_EOL;
+  pti->pending_eof = 0;
+  pti->alist = SCM_EOL;
 
   if (SCM_PORT_DESCRIPTOR (ret)->free)
     scm_i_set_finalizer (SCM2PTR (ret), finalize_port, NULL);
@@ -779,7 +815,7 @@ SCM_DEFINE (scm_close_port, "close-port", 1, 0, 0,
            "descriptors.")
 #define FUNC_NAME s_scm_close_port
 {
-  scm_t_port *p;
+  scm_t_port_internal *pti;
   int rv;
 
   port = SCM_COERCE_OUTPORT (port);
@@ -788,7 +824,7 @@ SCM_DEFINE (scm_close_port, "close-port", 1, 0, 0,
   if (SCM_CLOSEDP (port))
     return SCM_BOOL_F;
 
-  p = SCM_PTAB_ENTRY (port);
+  pti = SCM_PORT_GET_INTERNAL (port);
   SCM_CLR_PORT_OPEN_FLAG (port);
 
   if (SCM_PORT_DESCRIPTOR (port)->flags & SCM_PORT_TYPE_HAS_FLUSH)
@@ -801,12 +837,12 @@ SCM_DEFINE (scm_close_port, "close-port", 1, 0, 0,
   else
     rv = 0;
 
-  if (p->iconv_descriptors)
+  if (pti->iconv_descriptors)
     {
       /* If we don't get here, the iconv_descriptors finalizer will
          clean up. */
-      close_iconv_descriptors (p->iconv_descriptors);
-      p->iconv_descriptors = NULL;
+      close_iconv_descriptors (pti->iconv_descriptors);
+      pti->iconv_descriptors = NULL;
     }
 
   return scm_from_bool (rv >= 0);
@@ -971,6 +1007,66 @@ scm_i_set_default_port_conversion_handler 
(scm_t_string_failed_conversion_handle
 }
 
 static void
+scm_i_unget_bytes_unlocked (const unsigned char *buf, size_t len, SCM port);
+
+/* If the next LEN bytes from PORT are equal to those in BYTES, then
+   return 1, else return 0.  Leave the port position unchanged.  */
+static int
+looking_at_bytes (SCM port, const unsigned char *bytes, int len)
+{
+  scm_t_port *pt = SCM_PTAB_ENTRY (port);
+  int i = 0;
+
+  while (i < len && scm_peek_byte_or_eof_unlocked (port) == bytes[i])
+    {
+      pt->read_pos++;
+      i++;
+    }
+  scm_i_unget_bytes_unlocked (bytes, i, port);
+  return (i == len);
+}
+
+static const unsigned char scm_utf8_bom[3]    = {0xEF, 0xBB, 0xBF};
+static const unsigned char scm_utf16be_bom[2] = {0xFE, 0xFF};
+static const unsigned char scm_utf16le_bom[2] = {0xFF, 0xFE};
+static const unsigned char scm_utf32be_bom[4] = {0x00, 0x00, 0xFE, 0xFF};
+static const unsigned char scm_utf32le_bom[4] = {0xFF, 0xFE, 0x00, 0x00};
+
+/* Decide what byte order to use for a UTF-16 port.  Return "UTF-16BE"
+   or "UTF-16LE".  MODE must be either SCM_PORT_READ or SCM_PORT_WRITE,
+   and specifies which operation is about to be done.  The MODE
+   determines how we will decide the byte order.  We deliberately avoid
+   reading from the port unless the user is about to do so.  If the user
+   is about to read, then we look for a BOM, and if present, we use it
+   to determine the byte order.  Otherwise we choose big endian, as
+   recommended by the Unicode Standard.  Note that the BOM (if any) is
+   not consumed here.  */
+static const char *
+decide_utf16_encoding (SCM port, scm_t_port_rw_active mode)
+{
+  if (mode == SCM_PORT_READ
+      && SCM_PORT_GET_INTERNAL (port)->at_stream_start_for_bom_read
+      && looking_at_bytes (port, scm_utf16le_bom, sizeof scm_utf16le_bom))
+    return "UTF-16LE";
+  else
+    return "UTF-16BE";
+}
+
+/* Decide what byte order to use for a UTF-32 port.  Return "UTF-32BE"
+   or "UTF-32LE".  See the comment above 'decide_utf16_encoding' for
+   details.  */
+static const char *
+decide_utf32_encoding (SCM port, scm_t_port_rw_active mode)
+{
+  if (mode == SCM_PORT_READ
+      && SCM_PORT_GET_INTERNAL (port)->at_stream_start_for_bom_read
+      && looking_at_bytes (port, scm_utf32le_bom, sizeof scm_utf32le_bom))
+    return "UTF-32LE";
+  else
+    return "UTF-32BE";
+}
+
+static void
 finalize_iconv_descriptors (void *ptr, void *data)
 {
   close_iconv_descriptors (ptr);
@@ -1053,25 +1149,36 @@ close_iconv_descriptors (scm_t_iconv_descriptors *id)
 }
 
 scm_t_iconv_descriptors *
-scm_i_port_iconv_descriptors (SCM port)
+scm_i_port_iconv_descriptors (SCM port, scm_t_port_rw_active mode)
 {
-  scm_t_port *pt;
-
-  pt = SCM_PTAB_ENTRY (port);
+  scm_t_port_internal *pti = SCM_PORT_GET_INTERNAL (port);
 
-  assert (pt->encoding_mode == SCM_PORT_ENCODING_MODE_ICONV);
+  assert (pti->encoding_mode == SCM_PORT_ENCODING_MODE_ICONV);
 
-  if (!pt->iconv_descriptors)
+  if (!pti->iconv_descriptors)
     {
+      scm_t_port *pt = SCM_PTAB_ENTRY (port);
+      const char *precise_encoding;
+
       if (!pt->encoding)
         pt->encoding = "ISO-8859-1";
-      pt->iconv_descriptors =
-        open_iconv_descriptors (pt->encoding,
+
+      /* If the specified encoding is UTF-16 or UTF-32, then make
+         that more precise by deciding what byte order to use. */
+      if (strcmp (pt->encoding, "UTF-16") == 0)
+        precise_encoding = decide_utf16_encoding (port, mode);
+      else if (strcmp (pt->encoding, "UTF-32") == 0)
+        precise_encoding = decide_utf32_encoding (port, mode);
+      else
+        precise_encoding = pt->encoding;
+
+      pti->iconv_descriptors =
+        open_iconv_descriptors (precise_encoding,
                                 SCM_INPUT_PORT_P (port),
                                 SCM_OUTPUT_PORT_P (port));
     }
 
-  return pt->iconv_descriptors;
+  return pti->iconv_descriptors;
 }
 
 /* The name of the encoding is itself encoded in ASCII.  */
@@ -1079,36 +1186,39 @@ void
 scm_i_set_port_encoding_x (SCM port, const char *encoding)
 {
   scm_t_port *pt;
+  scm_t_port_internal *pti;
   scm_t_iconv_descriptors *prev;
 
   /* Set the character encoding for this port.  */
   pt = SCM_PTAB_ENTRY (port);
-  prev = pt->iconv_descriptors;
+  pti = SCM_PORT_GET_INTERNAL (port);
+  prev = pti->iconv_descriptors;
+
+  /* In order to handle cases where the encoding changes mid-stream
+     (e.g. within an HTTP stream, or within a file that is composed of
+     segments with different encodings), we consider this to be "stream
+     start" for purposes of BOM handling, regardless of our actual file
+     position. */
+  pti->at_stream_start_for_bom_read  = 1;
+  pti->at_stream_start_for_bom_write = 1;
 
   if (encoding_matches (encoding, "UTF-8"))
     {
       pt->encoding = "UTF-8";
-      pt->encoding_mode = SCM_PORT_ENCODING_MODE_UTF8;
-      pt->iconv_descriptors = NULL;
+      pti->encoding_mode = SCM_PORT_ENCODING_MODE_UTF8;
     }
   else if (encoding_matches (encoding, "ISO-8859-1"))
     {
       pt->encoding = "ISO-8859-1";
-      pt->encoding_mode = SCM_PORT_ENCODING_MODE_LATIN1;
-      pt->iconv_descriptors = NULL;
+      pti->encoding_mode = SCM_PORT_ENCODING_MODE_LATIN1;
     }
   else
     {
-      /* Open descriptors before mutating the port. */
-      char *gc_encoding = canonicalize_encoding (encoding);
-      pt->iconv_descriptors =
-        open_iconv_descriptors (gc_encoding,
-                                SCM_INPUT_PORT_P (port),
-                                SCM_OUTPUT_PORT_P (port));
-      pt->encoding = gc_encoding;
-      pt->encoding_mode = SCM_PORT_ENCODING_MODE_ICONV;
+      pt->encoding = canonicalize_encoding (encoding);
+      pti->encoding_mode = SCM_PORT_ENCODING_MODE_ICONV;
     }
 
+  pti->iconv_descriptors = NULL;
   if (prev)
     close_iconv_descriptors (prev);
 }
@@ -1334,17 +1444,21 @@ swap_buffer (void *data)
   psb->size = old_size;
 }
 
+static int scm_i_fill_input_unlocked (SCM port);
+
 size_t
 scm_c_read_unlocked (SCM port, void *buffer, size_t size)
 #define FUNC_NAME "scm_c_read"
 {
   scm_t_port *pt;
+  scm_t_port_internal *pti;
   size_t n_read = 0, n_available;
   struct port_and_swap_buffer psb;
 
   SCM_VALIDATE_OPINPORT (1, port);
 
   pt = SCM_PTAB_ENTRY (port);
+  pti = SCM_PORT_GET_INTERNAL (port);
   if (pt->rw_active == SCM_PORT_WRITE)
     SCM_PORT_DESCRIPTOR (port)->flush (port);
 
@@ -1366,24 +1480,23 @@ scm_c_read_unlocked (SCM port, void *buffer, size_t 
size)
   if (size == 0)
     return n_read;
 
-  /* Now we will call scm_fill_input repeatedly until we have read the
-     requested number of bytes.  (Note that a single scm_fill_input
-     call does not guarantee to fill the whole of the port's read
-     buffer.) */
+  /* Now we will call scm_i_fill_input_unlocked repeatedly until we have
+     read the requested number of bytes.  (Note that a single
+     scm_i_fill_input_unlocked call does not guarantee to fill the whole
+     of the port's read buffer.) */
   if (pt->read_buf_size <= 1
-      && pt->encoding_mode == SCM_PORT_ENCODING_MODE_LATIN1)
+      && pti->encoding_mode == SCM_PORT_ENCODING_MODE_LATIN1)
     {
-      /* The port that we are reading from is unbuffered - i.e. does
-        not have its own persistent buffer - but we have a buffer,
-        provided by our caller, that is the right size for the data
-        that is wanted.  For the following scm_fill_input calls,
-        therefore, we use the buffer in hand as the port's read
-        buffer.
-
-        We need to make sure that the port's normal (1 byte) buffer
-        is reinstated in case one of the scm_fill_input () calls
-        throws an exception; we use the scm_dynwind_* API to achieve
-        that. 
+      /* The port that we are reading from is unbuffered - i.e. does not
+        have its own persistent buffer - but we have a buffer, provided
+        by our caller, that is the right size for the data that is
+        wanted.  For the following scm_i_fill_input_unlocked calls,
+        therefore, we use the buffer in hand as the port's read buffer.
+
+        We need to make sure that the port's normal (1 byte) buffer is
+        reinstated in case one of the scm_i_fill_input_unlocked ()
+        calls throws an exception; we use the scm_dynwind_* API to
+        achieve that.
 
          A consequence of this optimization is that the fill_input
          functions can't unget characters.  That'll push data to the
@@ -1398,9 +1511,9 @@ scm_c_read_unlocked (SCM port, void *buffer, size_t size)
       scm_dynwind_rewind_handler (swap_buffer, &psb, SCM_F_WIND_EXPLICITLY);
       scm_dynwind_unwind_handler (swap_buffer, &psb, SCM_F_WIND_EXPLICITLY);
 
-      /* Call scm_fill_input until we have all the bytes that we need,
-        or we hit EOF. */
-      while (pt->read_buf_size && (scm_fill_input_unlocked (port) != EOF))
+      /* Call scm_i_fill_input_unlocked until we have all the bytes that
+        we need, or we hit EOF. */
+      while (pt->read_buf_size && (scm_i_fill_input_unlocked (port) != EOF))
        {
          pt->read_buf_size -= (pt->read_end - pt->read_pos);
          pt->read_pos = pt->read_buf = pt->read_end;
@@ -1424,7 +1537,7 @@ scm_c_read_unlocked (SCM port, void *buffer, size_t size)
         that a custom port implementation's entry points (in
         particular, fill_input) can rely on the buffer always being
         the same as they first set up. */
-      while (size && (scm_fill_input_unlocked (port) != EOF))
+      while (size && (scm_i_fill_input_unlocked (port) != EOF))
        {
          n_available = min (size, pt->read_end - pt->read_pos);
          memcpy (buffer, pt->read_pos, n_available);
@@ -1682,64 +1795,77 @@ get_iconv_codepoint (SCM port, scm_t_wchar *codepoint,
                     char buf[SCM_MBCHAR_BUF_SIZE], size_t *len)
 {
   scm_t_iconv_descriptors *id;
-  int err, byte_read;
-  size_t bytes_consumed, output_size;
-  char *output;
   scm_t_uint8 utf8_buf[SCM_MBCHAR_BUF_SIZE];
+  size_t input_size = 0;
 
-  id = scm_i_port_iconv_descriptors (port);
+  id = scm_i_port_iconv_descriptors (port, SCM_PORT_READ);
 
-  for (output_size = 0, output = (char *) utf8_buf,
-        bytes_consumed = 0, err = 0;
-       err == 0 && output_size == 0
-        && (bytes_consumed == 0 || byte_read != EOF);
-       bytes_consumed++)
+  for (;;)
     {
-      char *input;
+      int byte_read;
+      char *input, *output;
       size_t input_left, output_left, done;
 
       byte_read = scm_get_byte_or_eof_unlocked (port);
-      if (byte_read == EOF)
+      if (SCM_UNLIKELY (byte_read == EOF))
        {
-         if (bytes_consumed == 0)
-           {
-             *codepoint = (scm_t_wchar) EOF;
-             *len = 0;
-             return 0;
-           }
-         else
-           continue;
+          if (SCM_LIKELY (input_size == 0))
+            {
+              *codepoint = (scm_t_wchar) EOF;
+              *len = input_size;
+              return 0;
+            }
+          else
+            {
+              /* EOF found in the middle of a multibyte character. */
+              scm_i_set_pending_eof (port);
+              return EILSEQ;
+            }
        }
 
-      buf[bytes_consumed] = byte_read;
+      buf[input_size++] = byte_read;
 
       input = buf;
-      input_left = bytes_consumed + 1;
+      input_left = input_size;
+      output = (char *) utf8_buf;
       output_left = sizeof (utf8_buf);
 
       done = iconv (id->input_cd, &input, &input_left, &output, &output_left);
+
       if (done == (size_t) -1)
        {
-         err = errno;
-         if (err == EINVAL)
-           /* Missing input: keep trying.  */
-           err = 0;
+         int err = errno;
+         if (SCM_LIKELY (err == EINVAL))
+            /* The input byte sequence did not form a complete
+               character.  Read another byte and try again. */
+            continue;
+          else
+            return err;
        }
       else
-       output_size = sizeof (utf8_buf) - output_left;
-    }
-
-  if (SCM_UNLIKELY (output_size == 0))
-    /* An unterminated sequence.  */
-    err = EILSEQ;
-  else if (SCM_LIKELY (err == 0))
-    {
-      /* Convert the UTF8_BUF sequence to a Unicode code point.  */
-      *codepoint = utf8_to_codepoint (utf8_buf, output_size);
-      *len = bytes_consumed;
+        {
+          size_t output_size = sizeof (utf8_buf) - output_left;
+          if (SCM_LIKELY (output_size > 0))
+            {
+              /* iconv generated output.  Convert the UTF8_BUF sequence
+                 to a Unicode code point.  */
+              *codepoint = utf8_to_codepoint (utf8_buf, output_size);
+              *len = input_size;
+              return 0;
+            }
+          else
+            {
+              /* iconv consumed some bytes without producing any output.
+                 Most likely this means that a Unicode byte-order mark
+                 (BOM) was consumed, which should not be included in the
+                 returned buf.  Shift any remaining bytes to the beginning
+                 of buf, and continue the loop. */
+              memmove (buf, input, input_left);
+              input_size = input_left;
+              continue;
+            }
+        }
     }
-
-  return err;
 }
 
 /* Read a codepoint from PORT and return it in *CODEPOINT.  Fill BUF
@@ -1752,16 +1878,35 @@ get_codepoint (SCM port, scm_t_wchar *codepoint,
 {
   int err;
   scm_t_port *pt = SCM_PTAB_ENTRY (port);
+  scm_t_port_internal *pti = SCM_PORT_GET_INTERNAL (port);
 
-  if (pt->encoding_mode == SCM_PORT_ENCODING_MODE_UTF8)
+  if (pti->encoding_mode == SCM_PORT_ENCODING_MODE_UTF8)
     err = get_utf8_codepoint (port, codepoint, (scm_t_uint8 *) buf, len);
-  else if (pt->encoding_mode == SCM_PORT_ENCODING_MODE_LATIN1)
+  else if (pti->encoding_mode == SCM_PORT_ENCODING_MODE_LATIN1)
     err = get_latin1_codepoint (port, codepoint, buf, len);
   else
     err = get_iconv_codepoint (port, codepoint, buf, len);
 
   if (SCM_LIKELY (err == 0))
-    update_port_lf (*codepoint, port);
+    {
+      if (SCM_UNLIKELY (pti->at_stream_start_for_bom_read))
+        {
+          /* Record that we're no longer at stream start. */
+          pti->at_stream_start_for_bom_read = 0;
+          if (pt->rw_random)
+            pti->at_stream_start_for_bom_write = 0;
+
+          /* If we just read a BOM in an encoding that recognizes them,
+             then silently consume it and read another code point. */
+          if (SCM_UNLIKELY
+              (*codepoint == SCM_UNICODE_BOM
+               && (pti->encoding_mode == SCM_PORT_ENCODING_MODE_UTF8
+                   || strcmp (pt->encoding, "UTF-16") == 0
+                   || strcmp (pt->encoding, "UTF-32") == 0)))
+            return get_codepoint (port, codepoint, buf, len);
+        }
+      update_port_lf (*codepoint, port);
+    }
   else if (pt->ilseq_handler == SCM_ICONVEH_QUESTION_MARK)
     {
       *codepoint = '?';
@@ -1833,52 +1978,28 @@ SCM_DEFINE (scm_read_char, "read-char", 0, 1, 0,
 
 
 /* Pushback.  */
+
 
-void 
-scm_unget_byte_unlocked (int c, SCM port)
-#define FUNC_NAME "scm_unget_byte"
+
+static void
+scm_i_unget_bytes_unlocked (const unsigned char *buf, size_t len, SCM port)
+#define FUNC_NAME "scm_unget_bytes"
 {
   scm_t_port *pt = SCM_PTAB_ENTRY (port);
+  size_t old_len, new_len;
 
-  if (pt->read_buf == pt->putback_buf)
-    /* already using the put-back buffer.  */
-    {
-      /* enlarge putback_buf if necessary.  */
-      if (pt->read_end == pt->read_buf + pt->read_buf_size
-         && pt->read_buf == pt->read_pos)
-       {
-         size_t new_size = pt->read_buf_size * 2;
-         unsigned char *tmp = (unsigned char *)
-           scm_gc_realloc (pt->putback_buf, pt->read_buf_size, new_size,
-                           "putback buffer");
-
-         pt->read_pos = pt->read_buf = pt->putback_buf = tmp;
-         pt->read_end = pt->read_buf + pt->read_buf_size;
-         pt->read_buf_size = pt->putback_buf_size = new_size;
-       }
+  scm_i_clear_pending_eof (port);
 
-      /* shift any existing bytes to buffer + 1.  */
-      if (pt->read_pos == pt->read_end)
-       pt->read_end = pt->read_buf + 1;
-      else if (pt->read_pos != pt->read_buf + 1)
-       {
-         int count = pt->read_end - pt->read_pos;
-
-         memmove (pt->read_buf + 1, pt->read_pos, count);
-         pt->read_end = pt->read_buf + 1 + count;
-       }
-
-      pt->read_pos = pt->read_buf;
-    }
-  else
+  if (pt->read_buf != pt->putback_buf)
     /* switch to the put-back buffer.  */
     {
       if (pt->putback_buf == NULL)
        {
+          pt->putback_buf_size = (len > SCM_INITIAL_PUTBACK_BUF_SIZE
+                                  ? len : SCM_INITIAL_PUTBACK_BUF_SIZE);
          pt->putback_buf
            = (unsigned char *) scm_gc_malloc_pointerless
-           (SCM_INITIAL_PUTBACK_BUF_SIZE, "putback buffer");
-         pt->putback_buf_size = SCM_INITIAL_PUTBACK_BUF_SIZE;
+           (pt->putback_buf_size, "putback buffer");
        }
 
       pt->saved_read_buf = pt->read_buf;
@@ -1886,27 +2007,97 @@ scm_unget_byte_unlocked (int c, SCM port)
       pt->saved_read_end = pt->read_end;
       pt->saved_read_buf_size = pt->read_buf_size;
 
-      pt->read_pos = pt->read_buf = pt->putback_buf;
-      pt->read_end = pt->read_buf + 1;
+      /* Put read_pos at the end of the buffer, so that ungets will not
+         have to shift the buffer contents each time.  */
+      pt->read_buf = pt->putback_buf;
+      pt->read_pos = pt->read_end = pt->putback_buf + pt->putback_buf_size;
       pt->read_buf_size = pt->putback_buf_size;
     }
 
-  *pt->read_buf = c;
+  old_len = pt->read_end - pt->read_pos;
+  new_len = old_len + len;
+
+  if (new_len > pt->read_buf_size)
+    /* The putback buffer needs to be enlarged.  */
+    {
+      size_t new_buf_size;
+      unsigned char *new_buf, *new_end, *new_pos;
+
+      new_buf_size = pt->read_buf_size * 2;
+      if (new_buf_size < new_len)
+        new_buf_size = new_len;
+
+      new_buf = (unsigned char *)
+        scm_gc_malloc_pointerless (new_buf_size, "putback buffer");
+
+      /* Put the bytes at the end of the buffer, so that future
+         ungets won't need to shift the buffer.  */
+      new_end = new_buf + new_buf_size;
+      new_pos = new_end - old_len;
+      memcpy (new_pos, pt->read_pos, old_len);
+
+      pt->read_buf = pt->putback_buf = new_buf;
+      pt->read_pos = new_pos;
+      pt->read_end = new_end;
+      pt->read_buf_size = pt->putback_buf_size = new_buf_size;
+    }
+  else if (pt->read_buf + len < pt->read_pos)
+    /* If needed, shift the existing buffer contents up.
+       This should not happen unless some external code
+       manipulates the putback buffer pointers.  */
+    {
+      unsigned char *new_end = pt->read_buf + pt->read_buf_size;
+      unsigned char *new_pos = new_end - old_len;
+
+      memmove (new_pos, pt->read_pos, old_len);
+      pt->read_pos = new_pos;
+      pt->read_end = new_end;
+    }
+
+  /* Move read_pos back and copy the bytes there.  */
+  pt->read_pos -= len;
+  memcpy (pt->read_buf + (pt->read_pos - pt->read_buf), buf, len);
+
+  if (pt->rw_active == SCM_PORT_WRITE)
+    scm_flush (port);
 
   if (pt->rw_random)
     pt->rw_active = SCM_PORT_READ;
 }
 #undef FUNC_NAME
 
+void
+scm_unget_bytes_unlocked (const unsigned char *buf, size_t len, SCM port)
+{
+  scm_i_unget_bytes_unlocked (buf, len, port);
+}
+
+void
+scm_unget_byte_unlocked (int c, SCM port)
+{
+  unsigned char byte = c;
+  scm_i_unget_bytes_unlocked (&byte, 1, port);
+}
+
+void
+scm_unget_bytes (const unsigned char *buf, size_t len, SCM port)
+{
+  scm_i_pthread_mutex_t *lock;
+  scm_c_lock_port (port, &lock);
+  scm_i_unget_bytes_unlocked (buf, len, port);
+  if (lock)
+    scm_i_pthread_mutex_unlock (lock);
+}
+
 void 
 scm_unget_byte (int c, SCM port)
 {
+  unsigned char byte = c;
   scm_i_pthread_mutex_t *lock;
   scm_c_lock_port (port, &lock);
-  scm_unget_byte_unlocked (c, port);
+  scm_i_unget_bytes_unlocked (&byte, 1, port);
   if (lock)
     scm_i_pthread_mutex_unlock (lock);
-  
 }
 
 void
@@ -1917,7 +2108,6 @@ scm_ungetc_unlocked (scm_t_wchar c, SCM port)
   char *result;
   char result_buf[10];
   size_t len;
-  int i;
 
   len = sizeof (result_buf);
   result = u32_conv_to_encoding (pt->encoding,
@@ -1930,8 +2120,7 @@ scm_ungetc_unlocked (scm_t_wchar c, SCM port)
                        "conversion to port encoding failed",
                        SCM_BOOL_F, SCM_MAKE_CHAR (c));
 
-  for (i = len - 1; i >= 0; i--)
-    scm_unget_byte_unlocked (result[i], port);
+  scm_i_unget_bytes_unlocked ((unsigned char *) result, len, port);
 
   if (SCM_UNLIKELY (result != result_buf))
     free (result);
@@ -2010,7 +2199,7 @@ SCM_DEFINE (scm_peek_char, "peek-char", 0, 1, 0,
   SCM result;
   scm_t_wchar c;
   char bytes[SCM_MBCHAR_BUF_SIZE];
-  long column, line, i;
+  long column, line;
   size_t len;
 
   if (SCM_UNBNDP (port))
@@ -2022,8 +2211,7 @@ SCM_DEFINE (scm_peek_char, "peek-char", 0, 1, 0,
 
   err = get_codepoint (port, &c, bytes, &len);
 
-  for (i = len - 1; i >= 0; i--)
-    scm_unget_byte_unlocked (bytes[i], port);
+  scm_i_unget_bytes_unlocked ((unsigned char *) bytes, len, port);
 
   SCM_COL (port) = column;
   SCM_LINUM (port) = line;
@@ -2036,7 +2224,10 @@ SCM_DEFINE (scm_peek_char, "peek-char", 0, 1, 0,
       result = SCM_BOOL_F;
     }
   else if (c == EOF)
-    result = SCM_EOF_VAL;
+    {
+      scm_i_set_pending_eof (port);
+      result = SCM_EOF_VAL;
+    }
   else
     result = SCM_MAKE_CHAR (c);
 
@@ -2109,13 +2300,20 @@ scm_port_non_buffer (scm_t_port *pt)
 /* this should only be called when the read buffer is empty.  it
    tries to refill the read buffer.  it returns the first char from
    the port, which is either EOF or *(pt->read_pos).  */
-int
-scm_fill_input_unlocked (SCM port)
+static int
+scm_i_fill_input_unlocked (SCM port)
 {
   scm_t_port *pt = SCM_PTAB_ENTRY (port);
+  scm_t_port_internal *pti = SCM_PORT_GET_INTERNAL (port);
 
   assert (pt->read_pos == pt->read_end);
 
+  if (pti->pending_eof)
+    {
+      pti->pending_eof = 0;
+      return EOF;
+    }
+
   if (pt->read_buf == pt->putback_buf)
     {
       /* finished reading put-back chars.  */
@@ -2144,6 +2342,51 @@ scm_fill_input (SCM port)
   return ret;
 }
 
+/* Slow-path fallback for 'scm_get_byte_or_eof_unlocked' */
+int
+scm_slow_get_byte_or_eof_unlocked (SCM port)
+{
+  scm_t_port *pt = SCM_PTAB_ENTRY (port);
+
+  if (pt->rw_active == SCM_PORT_WRITE)
+    scm_flush_unlocked (port);
+
+  if (pt->rw_random)
+    pt->rw_active = SCM_PORT_READ;
+
+  if (pt->read_pos >= pt->read_end)
+    {
+      if (SCM_UNLIKELY (scm_i_fill_input_unlocked (port) == EOF))
+       return EOF;
+    }
+
+  return *pt->read_pos++;
+}
+
+/* Slow-path fallback for 'scm_peek_byte_or_eof_unlocked' */
+int
+scm_slow_peek_byte_or_eof_unlocked (SCM port)
+{
+  scm_t_port *pt = SCM_PTAB_ENTRY (port);
+
+  if (pt->rw_active == SCM_PORT_WRITE)
+    scm_flush_unlocked (port);
+
+  if (pt->rw_random)
+    pt->rw_active = SCM_PORT_READ;
+
+  if (pt->read_pos >= pt->read_end)
+    {
+      if (SCM_UNLIKELY (scm_i_fill_input_unlocked (port) == EOF))
+        {
+          scm_i_set_pending_eof (port);
+          return EOF;
+        }
+    }
+
+  return *pt->read_pos;
+}
+
 /* Move up to READ_LEN bytes from PORT's putback and/or read buffers
    into memory starting at DEST.  Return the number of bytes moved.
    PORT's line/column numbers are left unchanged.  */
@@ -2226,6 +2469,7 @@ scm_end_input_unlocked (SCM port)
   long offset;
   scm_t_port *pt = SCM_PTAB_ENTRY (port);
 
+  scm_i_clear_pending_eof (port);
   if (pt->read_buf == pt->putback_buf)
     {
       offset = pt->read_end - pt->read_pos;
@@ -2290,6 +2534,12 @@ scm_flush (SCM port)
   
 }
 
+int
+scm_fill_input_unlocked (SCM port)
+{
+  return scm_i_fill_input_unlocked (port);
+}
+
 
 
 
@@ -2499,6 +2749,7 @@ SCM_DEFINE (scm_seek, "seek", 3, 0, 0,
 
   if (SCM_OPPORTP (fd_port))
     {
+      scm_t_port_internal *pti = SCM_PORT_GET_INTERNAL (fd_port);
       scm_t_ptob_descriptor *ptob = SCM_PORT_DESCRIPTOR (fd_port);
       off_t_or_off64_t off = scm_to_off_t_or_off64_t (offset);
       off_t_or_off64_t rv;
@@ -2507,7 +2758,14 @@ SCM_DEFINE (scm_seek, "seek", 3, 0, 0,
        SCM_MISC_ERROR ("port is not seekable", 
                         scm_cons (fd_port, SCM_EOL));
       else
-       rv = ptob->seek (fd_port, off, how);
+        rv = ptob->seek (fd_port, off, how);
+
+      /* Set stream-start flags according to new position. */
+      pti->at_stream_start_for_bom_read  = (rv == 0);
+      pti->at_stream_start_for_bom_write = (rv == 0);
+
+      scm_i_clear_pending_eof (fd_port);
+
       return scm_from_off_t_or_off64_t (rv);
     }
   else /* file descriptor?.  */
@@ -2596,14 +2854,16 @@ SCM_DEFINE (scm_truncate_file, "truncate-file", 1, 1, 0,
       off_t_or_off64_t c_length = scm_to_off_t_or_off64_t (length);
       scm_t_port *pt = SCM_PTAB_ENTRY (object);
       scm_t_ptob_descriptor *ptob = SCM_PORT_DESCRIPTOR (object);
-      
+
       if (!ptob->truncate)
        SCM_MISC_ERROR ("port is not truncatable", SCM_EOL);
+
+      scm_i_clear_pending_eof (object);
       if (pt->rw_active == SCM_PORT_READ)
        scm_end_input_unlocked (object);
       else if (pt->rw_active == SCM_PORT_WRITE)
        ptob->flush (object);
-      
+
       ptob->truncate (object, c_length);
       rv = 0;
     }
diff --git a/libguile/ports.h b/libguile/ports.h
index c1ba719..80644898 100644
--- a/libguile/ports.h
+++ b/libguile/ports.h
@@ -4,7 +4,7 @@
 #define SCM_PORTS_H
 
 /* Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004,
- *   2006, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+ *   2006, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -48,20 +48,8 @@ typedef enum scm_t_port_rw_active {
   SCM_PORT_WRITE = 2
 } scm_t_port_rw_active;
 
-typedef enum scm_t_port_encoding_mode {
-  SCM_PORT_ENCODING_MODE_UTF8,
-  SCM_PORT_ENCODING_MODE_LATIN1,
-  SCM_PORT_ENCODING_MODE_ICONV
-} scm_t_port_encoding_mode;
-
-/* This is a separate object so that only those ports that use iconv
-   cause finalizers to be registered.  */
-typedef struct scm_t_iconv_descriptors
-{
-  /* input/output iconv conversion descriptors */
-  void *input_cd;
-  void *output_cd;
-} scm_t_iconv_descriptors;
+/* An internal-only structure defined in ports-internal.h. */
+struct scm_port_internal;
 
 /* C representation of a Scheme port.  */
 
@@ -70,6 +58,9 @@ typedef struct
   SCM port;                    /* Link back to the port object.  */
   scm_i_pthread_mutex_t *lock;  /* A recursive lock for this port.  */
 
+  /* pointer to internal-only port structure */
+  struct scm_port_internal *internal;
+
   /* data for the underlying port implementation as a raw C value. */
   scm_t_bits stream;
 
@@ -129,13 +120,7 @@ typedef struct
 
   /* Character encoding support  */
   char *encoding;
-  scm_t_port_encoding_mode encoding_mode;
   scm_t_string_failed_conversion_handler ilseq_handler;
-  scm_t_iconv_descriptors *iconv_descriptors;
-
-  /* an alist for storing additional information
-     (e.g. used to store per-port read options) */
-  SCM alist;
 } scm_t_port;
 
 
@@ -305,7 +290,6 @@ SCM_INTERNAL scm_t_string_failed_conversion_handler
 scm_i_default_port_conversion_handler (void);
 SCM_INTERNAL void
 scm_i_set_default_port_conversion_handler 
(scm_t_string_failed_conversion_handler);
-SCM_INTERNAL scm_t_iconv_descriptors *scm_i_port_iconv_descriptors (SCM port);
 SCM_INTERNAL void scm_i_set_port_encoding_x (SCM port, const char *str);
 SCM_API SCM scm_port_encoding (SCM port);
 SCM_API SCM scm_set_port_encoding_x (SCM port, SCM encoding);
@@ -320,8 +304,10 @@ SCM_INLINE int scm_c_try_lock_port (SCM port, 
scm_i_pthread_mutex_t **lock);
 /* Input.  */
 SCM_API int scm_get_byte_or_eof (SCM port);
 SCM_INLINE int scm_get_byte_or_eof_unlocked (SCM port);
+SCM_API int scm_slow_get_byte_or_eof_unlocked (SCM port);
 SCM_API int scm_peek_byte_or_eof (SCM port);
 SCM_INLINE int scm_peek_byte_or_eof_unlocked (SCM port);
+SCM_API int scm_slow_peek_byte_or_eof_unlocked (SCM port);
 SCM_API size_t scm_c_read (SCM port, void *buffer, size_t size);
 SCM_API size_t scm_c_read_unlocked (SCM port, void *buffer, size_t size);
 SCM_API scm_t_wchar scm_getc (SCM port);
@@ -329,6 +315,8 @@ SCM_API scm_t_wchar scm_getc_unlocked (SCM port);
 SCM_API SCM scm_read_char (SCM port);
 
 /* Pushback.  */
+SCM_API void scm_unget_bytes (const unsigned char *buf, size_t len, SCM port);
+SCM_API void scm_unget_bytes_unlocked (const unsigned char *buf, size_t len, 
SCM port);
 SCM_API void scm_unget_byte (int c, SCM port);
 SCM_API void scm_unget_byte_unlocked (int c, SCM port);
 SCM_API void scm_ungetc (scm_t_wchar c, SCM port);
@@ -374,6 +362,10 @@ SCM_API SCM scm_set_port_column_x (SCM port, SCM line);
 SCM_API SCM scm_port_filename (SCM port);
 SCM_API SCM scm_set_port_filename_x (SCM port, SCM filename);
 
+/* Port alist.  */
+SCM_INTERNAL SCM scm_i_port_alist (SCM port);
+SCM_INTERNAL void scm_i_set_port_alist_x (SCM port, SCM alist);
+
 /* Implementation helpers for port printing functions.  */
 SCM_API int scm_port_print (SCM exp, SCM port, scm_print_state *);
 SCM_API void scm_print_port_mode (SCM exp, SCM port);
@@ -423,50 +415,26 @@ scm_c_try_lock_port (SCM port, scm_i_pthread_mutex_t 
**lock)
 SCM_INLINE_IMPLEMENTATION int
 scm_get_byte_or_eof_unlocked (SCM port)
 {
-  int c;
   scm_t_port *pt = SCM_PTAB_ENTRY (port);
 
-  if (pt->rw_active == SCM_PORT_WRITE)
-    /* may be marginally faster than calling scm_flush.  */
-    SCM_PORT_DESCRIPTOR (port)->flush (port);
-
-  if (pt->rw_random)
-    pt->rw_active = SCM_PORT_READ;
-
-  if (pt->read_pos >= pt->read_end)
-    {
-      if (SCM_UNLIKELY (scm_fill_input_unlocked (port) == EOF))
-       return EOF;
-    }
-
-  c = *(pt->read_pos++);
-
-  return c;
+  if (SCM_LIKELY ((pt->rw_active == SCM_PORT_READ || !pt->rw_random)
+                  && pt->read_pos < pt->read_end))
+    return *pt->read_pos++;
+  else
+    return scm_slow_get_byte_or_eof_unlocked (port);
 }
 
 /* Like `scm_get_byte_or_eof' but does not change PORT's `read_pos'.  */
 SCM_INLINE_IMPLEMENTATION int
 scm_peek_byte_or_eof_unlocked (SCM port)
 {
-  int c;
   scm_t_port *pt = SCM_PTAB_ENTRY (port);
 
-  if (pt->rw_active == SCM_PORT_WRITE)
-    /* may be marginally faster than calling scm_flush.  */
-    SCM_PORT_DESCRIPTOR (port)->flush (port);
-
-  if (pt->rw_random)
-    pt->rw_active = SCM_PORT_READ;
-
-  if (pt->read_pos >= pt->read_end)
-    {
-      if (SCM_UNLIKELY (scm_fill_input_unlocked (port) == EOF))
-       return EOF;
-    }
-
-  c = *pt->read_pos;
-
-  return c;
+  if (SCM_LIKELY ((pt->rw_active == SCM_PORT_READ || !pt->rw_random)
+                  && pt->read_pos < pt->read_end))
+    return *pt->read_pos;
+  else
+    return scm_slow_peek_byte_or_eof_unlocked (port);
 }
 
 SCM_INLINE_IMPLEMENTATION void
diff --git a/libguile/posix.c b/libguile/posix.c
index b9097d4..822599d 100644
--- a/libguile/posix.c
+++ b/libguile/posix.c
@@ -32,23 +32,6 @@
 # include <sched.h>
 #endif
 
-#include "libguile/_scm.h"
-#include "libguile/dynwind.h"
-#include "libguile/fports.h"
-#include "libguile/scmsigs.h"
-#include "libguile/feature.h"
-#include "libguile/strings.h"
-#include "libguile/srfi-13.h"
-#include "libguile/srfi-14.h"
-#include "libguile/vectors.h"
-#include "libguile/values.h"
-
-#include "libguile/validate.h"
-#include "libguile/posix.h"
-#include "libguile/gettext.h"
-#include "libguile/threads.h"
-
-
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
@@ -65,10 +48,6 @@
 
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#else
-#ifndef ttyname
-extern char *ttyname();
-#endif
 #endif
 
 #ifdef LIBC_H_WITH_UNISTD_H
@@ -85,15 +64,23 @@ extern char *ttyname();
 #ifdef HAVE_IO_H
 #include <io.h>
 #endif
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h>
-#endif
 
-#ifdef __MINGW32__
-/* Some defines for Windows here. */
-# include <process.h>
-# define pipe(fd) _pipe (fd, 256, O_BINARY)
-#endif /* __MINGW32__ */
+#include "libguile/_scm.h"
+#include "libguile/dynwind.h"
+#include "libguile/fports.h"
+#include "libguile/scmsigs.h"
+#include "libguile/feature.h"
+#include "libguile/strings.h"
+#include "libguile/srfi-13.h"
+#include "libguile/srfi-14.h"
+#include "libguile/vectors.h"
+#include "libguile/values.h"
+
+#include "libguile/validate.h"
+#include "libguile/posix.h"
+#include "libguile/gettext.h"
+#include "libguile/threads.h"
+
 
 #if HAVE_SYS_WAIT_H
 # include <sys/wait.h>
@@ -168,6 +155,13 @@ extern char *ttyname();
 int sethostname (char *name, size_t namelen);
 #endif
 
+#if defined HAVE_GETLOGIN && !HAVE_DECL_GETLOGIN
+/* MinGW doesn't supply this decl; see
+   http://lists.gnu.org/archive/html/bug-gnulib/2013-03/msg00030.html for more
+   details.  */
+char *getlogin (void);
+#endif
+
 /* On NextStep, <utime.h> doesn't define struct utime, unless we
    #define _POSIX_SOURCE before #including it.  I think this is less
    of a kludge than defining struct utimbuf ourselves.  */
@@ -265,8 +259,10 @@ SCM_DEFINE (scm_getgroups, "getgroups", 0, 0, 0,
   GETGROUPS_T *groups;
 
   ngroups = getgroups (0, NULL);
-  if (ngroups <= 0)
+  if (ngroups < 0)
     SCM_SYSERROR;
+  else if (ngroups == 0)
+    return scm_c_make_vector (0, SCM_BOOL_F);
 
   size = ngroups * sizeof (GETGROUPS_T);
   groups = scm_malloc (size);
@@ -1146,12 +1142,7 @@ SCM_DEFINE (scm_execl, "execl", 1, 0, 1,
 
   exec_argv = scm_i_allocate_string_pointers (args);
 
-  execv (exec_file,
-#ifdef __MINGW32__
-         /* extra "const" in mingw formals, provokes warning from gcc */
-         (const char * const *)
-#endif
-         exec_argv);
+  execv (exec_file, exec_argv);
   SCM_SYSERROR;
 
   /* not reached.  */
@@ -1180,12 +1171,7 @@ SCM_DEFINE (scm_execlp, "execlp", 1, 0, 1,
 
   exec_argv = scm_i_allocate_string_pointers (args);
 
-  execvp (exec_file,
-#ifdef __MINGW32__
-          /* extra "const" in mingw formals, provokes warning from gcc */
-          (const char * const *)
-#endif
-          exec_argv);
+  execvp (exec_file, exec_argv);
   SCM_SYSERROR;
 
   /* not reached.  */
@@ -1219,17 +1205,7 @@ SCM_DEFINE (scm_execle, "execle", 2, 0, 1,
   exec_argv = scm_i_allocate_string_pointers (args);
   exec_env = scm_i_allocate_string_pointers (env);
 
-  execve (exec_file,
-#ifdef __MINGW32__
-          /* extra "const" in mingw formals, provokes warning from gcc */
-          (const char * const *)
-#endif
-          exec_argv,
-#ifdef __MINGW32__
-          /* extra "const" in mingw formals, provokes warning from gcc */
-          (const char * const *)
-#endif
-          exec_env);
+  execve (exec_file, exec_argv, exec_env);
   SCM_SYSERROR;
 
   /* not reached.  */
@@ -1430,12 +1406,7 @@ scm_open_process (SCM mode, SCM prog, SCM args)
       close (err);
     }
 
-  execvp (exec_file,
-#ifdef __MINGW32__
-          /* extra "const" in mingw formals, provokes warning from gcc */
-          (const char * const *)
-#endif
-          exec_argv);
+  execvp (exec_file, exec_argv);
 
   /* The exec failed!  There is nothing sensible to do.  */
   if (err > 0)
@@ -1636,6 +1607,12 @@ SCM_DEFINE (scm_utime, "utime", 1, 5, 0,
     struct utimbuf utm;
     utm.actime = atim_sec;
     utm.modtime = mtim_sec;
+    /* Silence warnings.  */
+    (void) atim_nsec;
+    (void) mtim_nsec;
+
+    if (f != 0)
+      scm_out_of_range(FUNC_NAME, flags);
 
     STRING_SYSCALL (pathname, c_pathname,
                     rv = utime (c_pathname, &utm));
@@ -1920,22 +1897,6 @@ SCM_DEFINE (scm_chroot, "chroot", 1, 0, 0,
 #undef FUNC_NAME
 #endif /* HAVE_CHROOT */
 
-
-#ifdef __MINGW32__
-/* Wrapper function to supplying `getlogin()' under Windows.  */
-static char * getlogin (void)
-{
-  static char user[256];
-  static unsigned long len = 256;
-
-  if (!GetUserName (user, &len))
-    return NULL;
-  return user;
-}
-#endif /* __MINGW32__ */
-
-
-#if defined (HAVE_GETLOGIN) || defined (__MINGW32__)
 SCM_DEFINE (scm_getlogin, "getlogin", 0, 0, 0, 
             (void),
            "Return a string containing the name of the user logged in on\n"
@@ -1951,7 +1912,6 @@ SCM_DEFINE (scm_getlogin, "getlogin", 0, 0, 0,
   return scm_from_locale_string (p);
 }
 #undef FUNC_NAME
-#endif /* HAVE_GETLOGIN */
 
 #if HAVE_GETPRIORITY
 SCM_DEFINE (scm_getpriority, "getpriority", 2, 0, 0, 
@@ -2377,6 +2337,7 @@ scm_init_posix ()
 #include "libguile/posix.x"
 
 #ifdef HAVE_FORK
+  scm_add_feature ("fork");
   scm_c_register_extension ("libguile-" SCM_EFFECTIVE_VERSION,
                             "scm_init_popen",
                            (scm_t_extension_init_func) scm_init_popen,
diff --git a/libguile/print.c b/libguile/print.c
index 26e4dfc..50f5a3e 100644
--- a/libguile/print.c
+++ b/libguile/print.c
@@ -1,5 +1,5 @@
 /* Copyright (C) 1995-1999, 2000, 2001, 2002, 2003, 2004, 2006, 2008,
- *   2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+ *   2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -44,6 +44,7 @@
 #include "libguile/alist.h"
 #include "libguile/struct.h"
 #include "libguile/ports.h"
+#include "libguile/ports-internal.h"
 #include "libguile/root.h"
 #include "libguile/strings.h"
 #include "libguile/strports.h"
@@ -656,8 +657,6 @@ iprin1 (SCM exp, SCM port, scm_print_state *pstate)
          scm_i_variable_print (exp, port, pstate);
          break;
        case scm_tc7_rtl_program:
-         scm_i_rtl_program_print (exp, port, pstate);
-         break;
        case scm_tc7_program:
          scm_i_program_print (exp, port, pstate);
          break;
@@ -950,8 +949,24 @@ display_string_using_iconv (const void *str, int narrow_p, 
size_t len,
 {
   size_t printed;
   scm_t_iconv_descriptors *id;
+  scm_t_port_internal *pti = SCM_PORT_GET_INTERNAL (port);
+
+  id = scm_i_port_iconv_descriptors (port, SCM_PORT_WRITE);
+
+  if (SCM_UNLIKELY (pti->at_stream_start_for_bom_write && len > 0))
+    {
+      scm_t_port *pt = SCM_PTAB_ENTRY (port);
+
+      /* Record that we're no longer at stream start.  */
+      pti->at_stream_start_for_bom_write = 0;
+      if (pt->rw_random)
+        pti->at_stream_start_for_bom_read = 0;
 
-  id = scm_i_port_iconv_descriptors (port);
+      /* Write a BOM if appropriate.  */
+      if (SCM_UNLIKELY (strcmp(pt->encoding, "UTF-16") == 0
+                        || strcmp(pt->encoding, "UTF-32") == 0))
+        display_character (SCM_UNICODE_BOM, port, iconveh_error);
+    }
 
   printed = 0;
 
@@ -1049,13 +1064,13 @@ display_string (const void *str, int narrow_p,
                size_t len, SCM port,
                scm_t_string_failed_conversion_handler strategy)
 {
-  scm_t_port *pt;
+  scm_t_port_internal *pti;
 
-  pt = SCM_PTAB_ENTRY (port);
+  pti = SCM_PORT_GET_INTERNAL (port);
 
-  if (pt->encoding_mode == SCM_PORT_ENCODING_MODE_UTF8)
+  if (pti->encoding_mode == SCM_PORT_ENCODING_MODE_UTF8)
     return display_string_as_utf8 (str, narrow_p, len, port);
-  else if (pt->encoding_mode == SCM_PORT_ENCODING_MODE_LATIN1)
+  else if (pti->encoding_mode == SCM_PORT_ENCODING_MODE_LATIN1)
     return display_string_as_latin1 (str, narrow_p, len, port, strategy);
   else
     return display_string_using_iconv (str, narrow_p, len, port, strategy);
diff --git a/libguile/procprop.c b/libguile/procprop.c
index d37495b..2d9e655 100644
--- a/libguile/procprop.c
+++ b/libguile/procprop.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995,1996,1998,2000,2001,2003,2004, 2006, 2008, 2009, 2010, 
2011, 2012 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1998,2000,2001,2003,2004, 2006, 2008, 2009, 2010, 
2011, 2012, 2013 Free Software Foundation, Inc.
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -60,7 +60,7 @@ scm_i_procedure_arity (SCM proc, int *req, int *opt, int 
*rest)
       return 1;
     }
 
-  while (!SCM_PROGRAM_P (proc))
+  while (!SCM_PROGRAM_P (proc) && !SCM_RTL_PROGRAM_P (proc))
     {
       if (SCM_STRUCTP (proc))
         {
@@ -82,14 +82,6 @@ scm_i_procedure_arity (SCM proc, int *req, int *opt, int 
*rest)
 
           return 1;
         }
-      else if (SCM_RTL_PROGRAM_P (proc))
-        {
-          *req = 0;
-          *opt = 0;
-          *rest = 1;
-
-          return 1;
-        }
       else
         return 0;
     }
@@ -154,6 +146,8 @@ SCM_DEFINE (scm_procedure_properties, 
"procedure-properties", 1, 0, 0,
     {
       if (SCM_PROGRAM_P (proc))
         ret = scm_i_program_properties (proc);
+      else if (SCM_RTL_PROGRAM_P (proc))
+        ret = scm_i_rtl_program_properties (proc);
       else
         ret = SCM_EOL;
     }
@@ -212,8 +206,99 @@ SCM_DEFINE (scm_set_procedure_property_x, 
"set-procedure-property!", 3, 0, 0,
 }
 #undef FUNC_NAME
 
+
 
 
+SCM_SYMBOL (scm_sym_source, "source");
+
+
+SCM_DEFINE (scm_procedure_name, "procedure-name", 1, 0, 0,
+            (SCM proc),
+           "Return the name of the procedure @var{proc}")
+#define FUNC_NAME s_scm_procedure_name
+{
+  SCM props, ret;
+
+  SCM_VALIDATE_PROC (1, proc);
+
+  while (SCM_STRUCTP (proc) && SCM_STRUCT_APPLICABLE_P (proc))
+    proc = SCM_STRUCT_PROCEDURE (proc);
+
+  props = scm_weak_table_refq (overrides, proc, SCM_BOOL_F);
+
+  if (scm_is_pair (props))
+    ret = scm_assq_ref (props, scm_sym_name);
+  else if (SCM_RTL_PROGRAM_P (proc))
+    ret = scm_i_rtl_program_name (proc);
+  else if (SCM_PROGRAM_P (proc))
+    ret = scm_assq_ref (scm_i_program_properties (proc), scm_sym_name);
+  else
+    ret = SCM_BOOL_F;
+  
+  return ret;
+}
+#undef FUNC_NAME
+
+
+SCM_GLOBAL_SYMBOL (scm_sym_documentation, "documentation");
+
+SCM_DEFINE (scm_procedure_documentation, "procedure-documentation", 1, 0, 0,
+           (SCM proc),
+           "Return the documentation string associated with @code{proc}.  By\n"
+           "convention, if a procedure contains more than one expression and 
the\n"
+           "first expression is a string constant, that string is assumed to 
contain\n"
+           "documentation for that procedure.")
+#define FUNC_NAME s_scm_procedure_documentation
+{
+  SCM props, ret;
+
+  SCM_VALIDATE_PROC (1, proc);
+
+  while (SCM_STRUCTP (proc) && SCM_STRUCT_APPLICABLE_P (proc))
+    proc = SCM_STRUCT_PROCEDURE (proc);
+
+  props = scm_weak_table_refq (overrides, proc, SCM_BOOL_F);
+
+  if (scm_is_pair (props))
+    ret = scm_assq_ref (props, scm_sym_documentation);
+  else if (SCM_RTL_PROGRAM_P (proc))
+    ret = scm_i_rtl_program_documentation (proc);
+  else if (SCM_PROGRAM_P (proc))
+    ret = scm_assq_ref (scm_i_program_properties (proc), 
scm_sym_documentation);
+  else
+    ret = SCM_BOOL_F;
+
+  return ret;
+}
+#undef FUNC_NAME
+
+
+SCM_DEFINE (scm_procedure_source, "procedure-source", 1, 0, 0,
+            (SCM proc),
+           "Return the source of the procedure @var{proc}.")
+#define FUNC_NAME s_scm_procedure_source
+{
+  SCM src;
+  SCM_VALIDATE_PROC (1, proc);
+
+  do
+    {
+      src = scm_procedure_property (proc, scm_sym_source);
+      if (scm_is_true (src))
+        return src;
+
+      if (SCM_STRUCTP (proc) && SCM_STRUCT_APPLICABLE_P (proc)
+          && SCM_HEAP_OBJECT_P ((proc = SCM_STRUCT_PROCEDURE (proc))))
+        continue;
+    }
+  while (0);
+
+  return SCM_BOOL_F;
+}
+#undef FUNC_NAME
+
+
+
 
 void
 scm_init_procprop ()
diff --git a/libguile/procprop.h b/libguile/procprop.h
index 88e44ec..41d0753 100644
--- a/libguile/procprop.h
+++ b/libguile/procprop.h
@@ -3,7 +3,7 @@
 #ifndef SCM_PROCPROP_H
 #define SCM_PROCPROP_H
 
-/* Copyright (C) 1995,1996,1998,2000, 2006, 2008, 2009, 2010, 2011 Free 
Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1998,2000, 2006, 2008, 2009, 2010, 2011, 2013 Free 
Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -29,6 +29,7 @@
 
 SCM_API SCM scm_sym_name;
 SCM_API SCM scm_sym_system_procedure;
+SCM_INTERNAL SCM scm_sym_documentation;
 
 
 
@@ -40,6 +41,9 @@ SCM_API SCM scm_procedure_properties (SCM proc);
 SCM_API SCM scm_set_procedure_properties_x (SCM proc, SCM alist);
 SCM_API SCM scm_procedure_property (SCM proc, SCM key);
 SCM_API SCM scm_set_procedure_property_x (SCM proc, SCM key, SCM val);
+SCM_API SCM scm_procedure_source (SCM proc);
+SCM_API SCM scm_procedure_name (SCM proc);
+SCM_API SCM scm_procedure_documentation (SCM proc);
 SCM_INTERNAL void scm_init_procprop (void);
 
 #endif  /* SCM_PROCPROP_H */
diff --git a/libguile/procs.c b/libguile/procs.c
index bda6d34..8d9ef15 100644
--- a/libguile/procs.c
+++ b/libguile/procs.c
@@ -66,21 +66,6 @@ SCM_DEFINE (scm_thunk_p, "thunk?", 1, 0, 0,
 }
 #undef FUNC_NAME
 
-SCM_GLOBAL_SYMBOL (scm_sym_documentation, "documentation");
-
-SCM_DEFINE (scm_procedure_documentation, "procedure-documentation", 1, 0, 0, 
-           (SCM proc),
-           "Return the documentation string associated with @code{proc}.  By\n"
-           "convention, if a procedure contains more than one expression and 
the\n"
-           "first expression is a string constant, that string is assumed to 
contain\n"
-           "documentation for that procedure.")
-#define FUNC_NAME s_scm_procedure_documentation
-{
-  SCM_VALIDATE_PROC (SCM_ARG1, proc);
-  return scm_procedure_property (proc, scm_sym_documentation);
-}
-#undef FUNC_NAME
-
 
 /* Procedure-with-setter
  */
diff --git a/libguile/procs.h b/libguile/procs.h
index a35872e..c4c78f2 100644
--- a/libguile/procs.h
+++ b/libguile/procs.h
@@ -4,7 +4,7 @@
 #define SCM_PROCS_H
 
 /* Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2006, 2008, 2009,
- *   2012 Free Software Foundation, Inc.
+ *   2012, 2013 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -30,15 +30,12 @@
 
 SCM_API SCM scm_procedure_p (SCM obj);
 SCM_API SCM scm_thunk_p (SCM obj);
-SCM_API SCM scm_procedure_documentation (SCM proc);
 SCM_API SCM scm_procedure_with_setter_p (SCM obj);
 SCM_API SCM scm_make_procedure_with_setter (SCM procedure, SCM setter);
 SCM_API SCM scm_procedure (SCM proc);
 SCM_API SCM scm_setter (SCM proc);
 SCM_INTERNAL void scm_init_procs (void);
 
-SCM_INTERNAL SCM scm_sym_documentation;
-
 #endif  /* SCM_PROCS_H */
 
 /*
diff --git a/libguile/programs.c b/libguile/programs.c
index 971ea9d..d8dd378 100644
--- a/libguile/programs.c
+++ b/libguile/programs.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, 
Inc.
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -99,14 +99,53 @@ SCM_DEFINE (scm_make_rtl_program, "make-rtl-program", 1, 2, 
0,
 }
 #undef FUNC_NAME
 
-void
-scm_i_rtl_program_print (SCM program, SCM port, scm_print_state *pstate)
+SCM_DEFINE (scm_rtl_program_code, "rtl-program-code", 1, 0, 0,
+            (SCM program),
+            "")
+#define FUNC_NAME s_scm_rtl_program_code
+{
+  SCM_VALIDATE_RTL_PROGRAM (1, program);
+
+  /* FIXME: we need scm_from_uintptr ().  */
+  return scm_from_size_t ((size_t) SCM_RTL_PROGRAM_CODE (program));
+}
+#undef FUNC_NAME
+
+SCM
+scm_i_rtl_program_name (SCM program)
+{
+  static SCM rtl_program_name = SCM_BOOL_F;
+
+  if (scm_is_false (rtl_program_name) && scm_module_system_booted_p)
+    rtl_program_name =
+        scm_c_private_variable ("system vm program", "rtl-program-name");
+
+  return scm_call_1 (scm_variable_ref (rtl_program_name), program);
+}
+
+SCM
+scm_i_rtl_program_documentation (SCM program)
 {
-  scm_puts_unlocked ("#<rtl-program ", port);
-  scm_uintprint (SCM_UNPACK (program), 16, port);
-  scm_putc_unlocked (' ', port);
-  scm_uintprint ((scm_t_uintptr) SCM_RTL_PROGRAM_CODE (program), 16, port);
-  scm_putc_unlocked ('>', port);
+  static SCM rtl_program_documentation = SCM_BOOL_F;
+
+  if (scm_is_false (rtl_program_documentation) && scm_module_system_booted_p)
+    rtl_program_documentation =
+      scm_c_private_variable ("system vm program",
+                              "rtl-program-documentation");
+
+  return scm_call_1 (scm_variable_ref (rtl_program_documentation), program);
+}
+
+SCM
+scm_i_rtl_program_properties (SCM program)
+{
+  static SCM rtl_program_properties = SCM_BOOL_F;
+
+  if (scm_is_false (rtl_program_properties) && scm_module_system_booted_p)
+    rtl_program_properties =
+      scm_c_private_variable ("system vm program", "rtl-program-properties");
+
+  return scm_call_1 (scm_variable_ref (rtl_program_properties), program);
 }
 
 void
@@ -115,9 +154,8 @@ scm_i_program_print (SCM program, SCM port, scm_print_state 
*pstate)
   static int print_error = 0;
 
   if (scm_is_false (write_program) && scm_module_system_booted_p)
-    write_program = scm_module_local_variable
-      (scm_c_resolve_module ("system vm program"),
-       scm_from_latin1_symbol ("write-program"));
+    write_program = scm_c_private_variable ("system vm program",
+                                            "write-program");
   
   if (SCM_PROGRAM_IS_CONTINUATION (program))
     {
@@ -135,9 +173,20 @@ scm_i_program_print (SCM program, SCM port, 
scm_print_state *pstate)
     }
   else if (scm_is_false (write_program) || print_error)
     {
-      scm_puts_unlocked ("#<program ", port);
-      scm_uintprint (SCM_UNPACK (program), 16, port);
-      scm_putc_unlocked ('>', port);
+      if (SCM_RTL_PROGRAM_P (program))
+        {
+          scm_puts_unlocked ("#<rtl-program ", port);
+          scm_uintprint (SCM_UNPACK (program), 16, port);
+          scm_putc_unlocked (' ', port);
+          scm_uintprint ((scm_t_uintptr) SCM_RTL_PROGRAM_CODE (program), 16, 
port);
+          scm_putc_unlocked ('>', port);
+        }
+      else
+        {
+          scm_puts_unlocked ("#<program ", port);
+          scm_uintprint (SCM_UNPACK (program), 16, port);
+          scm_putc_unlocked ('>', port);
+        }
     }
   else
     {
@@ -161,6 +210,15 @@ SCM_DEFINE (scm_program_p, "program?", 1, 0, 0,
 }
 #undef FUNC_NAME
 
+SCM_DEFINE (scm_rtl_program_p, "rtl-program?", 1, 0, 0,
+           (SCM obj),
+           "")
+#define FUNC_NAME s_scm_rtl_program_p
+{
+  return scm_from_bool (SCM_RTL_PROGRAM_P (obj));
+}
+#undef FUNC_NAME
+
 SCM_DEFINE (scm_program_base, "program-base", 1, 0, 0,
            (SCM program),
            "")
@@ -416,11 +474,36 @@ parse_arity (SCM arity, int *req, int *opt, int *rest)
     *req = *opt = *rest = 0;
 }
   
+static int
+scm_i_rtl_program_minimum_arity (SCM program, int *req, int *opt, int *rest)
+{
+  static SCM rtl_program_minimum_arity = SCM_BOOL_F;
+  SCM l;
+
+  if (scm_is_false (rtl_program_minimum_arity) && scm_module_system_booted_p)
+    rtl_program_minimum_arity =
+        scm_c_private_variable ("system vm debug",
+                                "rtl-program-minimum-arity");
+
+  l = scm_call_1 (scm_variable_ref (rtl_program_minimum_arity), program);
+  if (scm_is_false (l))
+    return 0;
+
+  *req = scm_to_int (scm_car (l));
+  *opt = scm_to_int (scm_cadr (l));
+  *rest = scm_is_true (scm_caddr (l));
+
+  return 1;
+}
+
 int
 scm_i_program_arity (SCM program, int *req, int *opt, int *rest)
 {
   SCM arities;
   
+  if (SCM_RTL_PROGRAM_P (program))
+    return scm_i_rtl_program_minimum_arity (program, req, opt, rest);
+
   arities = scm_program_arities (program);
   if (!scm_is_pair (arities))
     return 0;
diff --git a/libguile/programs.h b/libguile/programs.h
index f2d519c..e42a76e 100644
--- a/libguile/programs.h
+++ b/libguile/programs.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, 
Inc.
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -32,6 +32,7 @@
 #define SCM_RTL_PROGRAM_FREE_VARIABLE_REF(x,i) (SCM_RTL_PROGRAM_FREE_VARIABLES 
(x)[i])
 #define SCM_RTL_PROGRAM_FREE_VARIABLE_SET(x,i,v) 
(SCM_RTL_PROGRAM_FREE_VARIABLES (x)[i]=(v))
 #define SCM_RTL_PROGRAM_NUM_FREE_VARIABLES(x) (SCM_CELL_WORD_0 (x) >> 16)
+#define SCM_VALIDATE_RTL_PROGRAM(p,x) SCM_MAKE_VALIDATE (p, x, RTL_PROGRAM_P)
 
 static inline SCM
 scm_i_make_rtl_program (const scm_t_uint32 *code)
@@ -40,9 +41,12 @@ scm_i_make_rtl_program (const scm_t_uint32 *code)
 }
 
 SCM_INTERNAL SCM scm_make_rtl_program (SCM bytevector, SCM byte_offset, SCM 
free_variables);
+SCM_INTERNAL SCM scm_rtl_program_p (SCM obj);
+SCM_INTERNAL SCM scm_rtl_program_code (SCM program);
 
-SCM_INTERNAL void scm_i_rtl_program_print (SCM program, SCM port,
-                                           scm_print_state *pstate);
+SCM_INTERNAL SCM scm_i_rtl_program_name (SCM program);
+SCM_INTERNAL SCM scm_i_rtl_program_documentation (SCM program);
+SCM_INTERNAL SCM scm_i_rtl_program_properties (SCM program);
 
 /*
  * Programs
diff --git a/libguile/r6rs-ports.c b/libguile/r6rs-ports.c
index 60ba38c..c6ad90a 100644
--- a/libguile/r6rs-ports.c
+++ b/libguile/r6rs-ports.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
+/* Copyright (C) 2009, 2010, 2011, 2013 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -480,16 +480,11 @@ SCM_DEFINE (scm_get_bytevector_n, "get-bytevector-n", 2, 
0, 0,
     /* Don't invoke `scm_c_read ()' since it may block.  */
     c_read = 0;
 
-  if ((c_read == 0) && (c_count > 0))
+  if (c_read < c_count)
     {
-      if (SCM_EOF_OBJECT_P (scm_peek_char (port)))
-       result = SCM_EOF_VAL;
+      if (c_read == 0)
+        result = SCM_EOF_VAL;
       else
-       result = scm_null_bytevector;
-    }
-  else
-    {
-      if (c_read < c_count)
        result = scm_c_shrink_bytevector (result, c_read);
     }
 
@@ -527,13 +522,8 @@ SCM_DEFINE (scm_get_bytevector_n_x, "get-bytevector-n!", 
4, 0, 0,
     /* Don't invoke `scm_c_read ()' since it may block.  */
     c_read = 0;
 
-  if ((c_read == 0) && (c_count > 0))
-    {
-      if (SCM_EOF_OBJECT_P (scm_peek_char (port)))
-       result = SCM_EOF_VAL;
-      else
-       result = SCM_I_MAKINUM (0);
-    }
+  if (c_read == 0 && c_count > 0)
+    result = SCM_EOF_VAL;
   else
     result = scm_from_size_t (c_read);
 
@@ -544,69 +534,41 @@ SCM_DEFINE (scm_get_bytevector_n_x, "get-bytevector-n!", 
4, 0, 0,
 
 SCM_DEFINE (scm_get_bytevector_some, "get-bytevector-some", 1, 0, 0,
            (SCM port),
-           "Read from @var{port}, blocking as necessary, until data "
-           "are available or and end-of-file is reached.  Return either "
-           "a new bytevector containing the data read or the "
-           "end-of-file object.")
+            "Read from @var{port}, blocking as necessary, until bytes "
+            "are available or an end-of-file is reached.  Return either "
+            "the end-of-file object or a new bytevector containing some "
+            "of the available bytes (at least one), and update the port "
+            "position to point just past these bytes.")
 #define FUNC_NAME s_scm_get_bytevector_some
 {
-  /* Read at least one byte, unless the end-of-file is already reached, and
-     read while characters are available (buffered).  */
-
-  SCM result;
-  char *c_bv;
-  unsigned c_len;
-  size_t c_total;
+  scm_t_port *pt;
+  size_t size;
+  SCM bv;
 
   SCM_VALIDATE_BINARY_INPUT_PORT (1, port);
+  pt = SCM_PTAB_ENTRY (port);
 
-  c_len = 4096;
-  c_bv = (char *) scm_gc_malloc_pointerless (c_len, SCM_GC_BYTEVECTOR);
-  c_total = 0;
-
-  do
-    {
-      int c_chr;
-
-      if (c_total + 1 > c_len)
-       {
-         /* Grow the bytevector.  */
-         c_bv = (char *) scm_gc_realloc (c_bv, c_len, c_len * 2,
-                                         SCM_GC_BYTEVECTOR);
-         c_len *= 2;
-       }
+  if (pt->rw_active == SCM_PORT_WRITE)
+    scm_flush_unlocked (port);
 
-      /* We can't use `scm_c_read ()' since it blocks.  */
-      c_chr = scm_getc_unlocked (port);
-      if (c_chr != EOF)
-       {
-         c_bv[c_total] = (char) c_chr;
-         c_total++;
-       }
-    }
-  while ((scm_is_true (scm_char_ready_p (port)))
-        && (!SCM_EOF_OBJECT_P (scm_peek_char (port))));
+  if (pt->rw_random)
+    pt->rw_active = SCM_PORT_READ;
 
-  if (c_total == 0)
+  if (pt->read_pos >= pt->read_end)
     {
-      result = SCM_EOF_VAL;
-      scm_gc_free (c_bv, c_len, SCM_GC_BYTEVECTOR);
+      if (scm_fill_input_unlocked (port) == EOF)
+       return SCM_EOF_VAL;
     }
-  else
-    {
-      if (c_len > c_total)
-       {
-         /* Shrink the bytevector.  */
-         c_bv = (char *) scm_gc_realloc (c_bv, c_len, c_total,
-                                         SCM_GC_BYTEVECTOR);
-         c_len = (unsigned) c_total;
-       }
 
-      result = scm_c_take_gc_bytevector ((signed char *) c_bv, c_len,
-                                         SCM_BOOL_F);
-    }
+  size = pt->read_end - pt->read_pos;
+  if (pt->read_buf == pt->putback_buf)
+    size += pt->saved_read_end - pt->saved_read_pos;
 
-  return result;
+  bv = scm_c_make_bytevector (size);
+  scm_take_from_input_buffers
+    (port, (char *) SCM_BYTEVECTOR_CONTENTS (bv), size);
+
+  return bv;
 }
 #undef FUNC_NAME
 
@@ -645,7 +607,7 @@ SCM_DEFINE (scm_get_bytevector_all, "get-bytevector-all", 
1, 0, 0,
       c_read = scm_c_read_unlocked (port, c_bv + c_total, c_count);
       c_total += c_read, c_count -= c_read;
     }
-  while (!SCM_EOF_OBJECT_P (scm_peek_char (port)));
+  while (c_count == 0);
 
   if (c_total == 0)
     {
@@ -737,6 +699,49 @@ SCM_DEFINE (scm_put_bytevector, "put-bytevector", 2, 2, 0,
 }
 #undef FUNC_NAME
 
+SCM_DEFINE (scm_unget_bytevector, "unget-bytevector", 2, 2, 0,
+           (SCM port, SCM bv, SCM start, SCM count),
+           "Unget the contents of @var{bv} to @var{port}, optionally "
+           "starting at index @var{start} and limiting to @var{count} "
+           "octets.")
+#define FUNC_NAME s_scm_unget_bytevector
+{
+  unsigned char *c_bv;
+  size_t c_start, c_count, c_len;
+
+  SCM_VALIDATE_BINARY_INPUT_PORT (1, port);
+  SCM_VALIDATE_BYTEVECTOR (2, bv);
+
+  c_len = SCM_BYTEVECTOR_LENGTH (bv);
+  c_bv = (unsigned char *) SCM_BYTEVECTOR_CONTENTS (bv);
+
+  if (!scm_is_eq (start, SCM_UNDEFINED))
+    {
+      c_start = scm_to_size_t (start);
+
+      if (!scm_is_eq (count, SCM_UNDEFINED))
+       {
+         c_count = scm_to_size_t (count);
+         if (SCM_UNLIKELY (c_start + c_count > c_len))
+           scm_out_of_range (FUNC_NAME, count);
+       }
+      else
+       {
+         if (SCM_UNLIKELY (c_start >= c_len))
+           scm_out_of_range (FUNC_NAME, start);
+         else
+           c_count = c_len - c_start;
+       }
+    }
+  else
+    c_start = 0, c_count = c_len;
+
+  scm_unget_bytes (c_bv + c_start, c_count, port);
+
+  return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+
 
 
 /* Bytevector output port ("bop" for short).  */
diff --git a/libguile/random.c b/libguile/random.c
index 2db19f7..c0b04bc 100644
--- a/libguile/random.c
+++ b/libguile/random.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1999,2000,2001, 2003, 2005, 2006, 2009, 2010 Free Software 
Foundation, Inc.
+/* Copyright (C) 1999, 2000, 2001, 2003, 2005, 2006, 2009, 2010,
+ *    2012, 2013 Free Software Foundation, Inc.
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
  * as published by the Free Software Foundation; either version 3 of
@@ -17,7 +18,7 @@
 
 
 
-/* Author: Mikael Djurfeldt <address@hidden> */
+/* Original Author: Mikael Djurfeldt <address@hidden> */
 
 #ifdef HAVE_CONFIG_H
 #  include <config.h>
@@ -29,6 +30,12 @@
 #include <stdio.h>
 #include <math.h>
 #include <string.h>
+#include <sys/types.h>
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
 #include "libguile/smob.h"
 #include "libguile/numbers.h"
 #include "libguile/feature.h"
@@ -665,7 +672,8 @@ random_state_of_last_resort (void)
   SCM time_of_day = scm_gettimeofday ();
   SCM sources = scm_list_n
     (scm_from_unsigned_integer (SCM_UNPACK (time_of_day)),  /* heap addr */
-     scm_getpid (),         /* process ID */
+     /* Avoid scm_getpid, since it depends on HAVE_POSIX. */
+     scm_from_unsigned_integer (getpid ()),                 /* process ID */
      scm_get_internal_real_time (), /* high-resolution process timer */
      scm_from_unsigned_integer ((scm_t_bits) &time_of_day), /* stack addr */
      scm_car (time_of_day), /* seconds since midnight 1970-01-01 UTC */
diff --git a/libguile/read.c b/libguile/read.c
index 7c003b4..c8db812 100644
--- a/libguile/read.c
+++ b/libguile/read.c
@@ -29,6 +29,7 @@
 #include <unistd.h>
 #include <unicase.h>
 #include <unictype.h>
+#include <c-strcase.h>
 
 #include "libguile/_scm.h"
 #include "libguile/bytevectors.h"
@@ -42,6 +43,7 @@
 #include "libguile/hashtab.h"
 #include "libguile/hash.h"
 #include "libguile/ports.h"
+#include "libguile/ports-internal.h"
 #include "libguile/fports.h"
 #include "libguile/root.h"
 #include "libguile/strings.h"
@@ -968,7 +970,7 @@ scm_read_character (scm_t_wchar chr, SCM port, 
scm_t_read_opts *opts)
   size_t charname_len, bytes_read;
   scm_t_wchar cp;
   int overflow;
-  scm_t_port *pt;
+  scm_t_port_internal *pti;
 
   overflow = read_token (port, opts, buffer, READER_CHAR_NAME_MAX_SIZE,
                          &bytes_read);
@@ -986,14 +988,14 @@ scm_read_character (scm_t_wchar chr, SCM port, 
scm_t_read_opts *opts)
       return (SCM_MAKE_CHAR (chr));
     }
 
-  pt = SCM_PTAB_ENTRY (port);
+  pti = SCM_PORT_GET_INTERNAL (port);
 
   /* Simple ASCII characters can be processed immediately.  Also, simple
      ISO-8859-1 characters can be processed immediately if the encoding for 
this
      port is ISO-8859-1.  */
   if (bytes_read == 1 &&
       ((unsigned char) buffer[0] <= 127
-       || pt->encoding_mode == SCM_PORT_ENCODING_MODE_LATIN1))
+       || pti->encoding_mode == SCM_PORT_ENCODING_MODE_LATIN1))
     {
       SCM_COL (port) += 1;
       return SCM_MAKE_CHAR (buffer[0]);
@@ -1969,7 +1971,6 @@ scm_i_scan_for_encoding (SCM port)
   char header[SCM_ENCODING_SEARCH_SIZE+1];
   size_t bytes_read, encoding_length, i;
   char *encoding = NULL;
-  int utf8_bom = 0;
   char *pos, *encoding_start;
   int in_comment;
 
@@ -2014,10 +2015,6 @@ scm_i_scan_for_encoding (SCM port)
       scm_seek (port, scm_from_int (0), scm_from_int (SEEK_SET));
     }
 
-  if (bytes_read > 3 
-      && header[0] == '\xef' && header[1] == '\xbb' && header[2] == '\xbf')
-    utf8_bom = 1;
-
   /* search past "coding[:=]" */
   pos = header;
   while (1)
@@ -2083,11 +2080,6 @@ scm_i_scan_for_encoding (SCM port)
     /* This wasn't in a comment */
     return NULL;
 
-  if (utf8_bom && strcasecmp (encoding, "UTF-8"))
-    scm_misc_error (NULL,
-                   "the port input declares the encoding ~s but is encoded as 
UTF-8",
-                   scm_list_1 (scm_from_locale_string (encoding)));
-
   return encoding;
 }
 
@@ -2112,7 +2104,7 @@ SCM_DEFINE (scm_file_encoding, "file-encoding", 1, 0, 0,
     return SCM_BOOL_F;
   else
     {
-      s_enc = scm_from_locale_string (enc);
+      s_enc = scm_string_upcase (scm_from_locale_string (enc));
       return s_enc;
     }
 
@@ -2124,8 +2116,9 @@ SCM_DEFINE (scm_file_encoding, "file-encoding", 1, 0, 0,
 /* Per-port read options.
 
    We store per-port read options in the 'port-read-options' key of the
-   port's alist.  The value stored in the alist is a single integer that
-   contains a two-bit field for each read option.
+   port's alist, which is stored in the internal port structure.  The
+   value stored in the alist is a single integer that contains a two-bit
+   field for each read option.
 
    If a bit field contains READ_OPTION_INHERIT (3), that indicates that
    the applicable value should be inherited from the corresponding
@@ -2160,12 +2153,12 @@ SCM_SYMBOL (sym_port_read_options, "port-read-options");
 static void
 set_port_read_option (SCM port, int option, int new_value)
 {
-  SCM scm_read_options;
+  SCM alist, scm_read_options;
   unsigned int read_options;
 
   new_value &= READ_OPTION_MASK;
-  scm_read_options = scm_assq_ref (SCM_PTAB_ENTRY(port)->alist,
-                                   sym_port_read_options);
+  alist = scm_i_port_alist (port);
+  scm_read_options = scm_assq_ref (alist, sym_port_read_options);
   if (scm_is_unsigned_integer (scm_read_options, 0, READ_OPTIONS_MAX_VALUE))
     read_options = scm_to_uint (scm_read_options);
   else
@@ -2173,9 +2166,8 @@ set_port_read_option (SCM port, int option, int new_value)
   read_options &= ~(READ_OPTION_MASK << option);
   read_options |= new_value << option;
   scm_read_options = scm_from_uint (read_options);
-  SCM_PTAB_ENTRY(port)->alist = scm_assq_set_x (SCM_PTAB_ENTRY(port)->alist,
-                                                sym_port_read_options,
-                                                scm_read_options);
+  alist = scm_assq_set_x (alist, sym_port_read_options, scm_read_options);
+  scm_i_set_port_alist_x (port, alist);
 }
 
 /* Set OPTS and PORT's case-insensitivity according to VALUE. */
@@ -2210,11 +2202,11 @@ set_port_curly_infix_p (SCM port, scm_t_read_opts 
*opts, int value)
 static void
 init_read_options (SCM port, scm_t_read_opts *opts)
 {
-  SCM val, scm_read_options;
+  SCM alist, val, scm_read_options;
   unsigned int read_options, x;
 
-  scm_read_options = scm_assq_ref (SCM_PTAB_ENTRY(port)->alist,
-                                   sym_port_read_options);
+  alist = scm_i_port_alist (port);
+  scm_read_options = scm_assq_ref (alist, sym_port_read_options);
 
   if (scm_is_unsigned_integer (scm_read_options, 0, READ_OPTIONS_MAX_VALUE))
     read_options = scm_to_uint (scm_read_options);
diff --git a/libguile/scmsigs.c b/libguile/scmsigs.c
index 86fce0f..497da2f 100644
--- a/libguile/scmsigs.c
+++ b/libguile/scmsigs.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2004, 2006, 2007, 
2008, 2009, 2011 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2002, 2004, 2006, 2007, 
2008, 2009, 2011, 2013 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -28,17 +28,6 @@
 #include <stdio.h>
 #include <errno.h>
 
-#include "libguile/_scm.h"
-
-#include "libguile/async.h"
-#include "libguile/eval.h"
-#include "libguile/root.h"
-#include "libguile/vectors.h"
-#include "libguile/threads.h"
-
-#include "libguile/validate.h"
-#include "libguile/scmsigs.h"
-
 #ifdef HAVE_PROCESS_H
 #include <process.h>    /* for mingw */
 #endif
@@ -51,16 +40,19 @@
 #include <sys/time.h>
 #endif
 
-#ifdef __MINGW32__
-#include <windows.h>
-#define alarm(sec) (0)
-/* This weird comma expression is because Sleep is void under Windows. */
-#define sleep(sec) (Sleep ((sec) * 1000), 0)
-#define usleep(usec) (Sleep ((usec) / 1000), 0)
-#endif
-
 #include <full-write.h>
 
+#include "libguile/_scm.h"
+
+#include "libguile/async.h"
+#include "libguile/eval.h"
+#include "libguile/root.h"
+#include "libguile/vectors.h"
+#include "libguile/threads.h"
+
+#include "libguile/validate.h"
+#include "libguile/scmsigs.h"
+
 
 
 
@@ -526,6 +518,7 @@ SCM_DEFINE (scm_restore_signals, "restore-signals", 0, 0, 0,
 }
 #undef FUNC_NAME
 
+#if defined HAVE_ALARM && HAVE_DECL_ALARM
 SCM_DEFINE (scm_alarm, "alarm", 1, 0, 0,
            (SCM i),
            "Set a timer to raise a @code{SIGALRM} signal after the specified\n"
@@ -541,6 +534,7 @@ SCM_DEFINE (scm_alarm, "alarm", 1, 0, 0,
   return scm_from_uint (alarm (scm_to_uint (i)));
 }
 #undef FUNC_NAME
+#endif /* HAVE_ALARM */
 
 #ifdef HAVE_SETITIMER
 SCM_DEFINE (scm_setitimer, "setitimer", 5, 0, 0,
diff --git a/libguile/smob.c b/libguile/smob.c
index c2347f3..857773c 100644
--- a/libguile/smob.c
+++ b/libguile/smob.c
@@ -1,5 +1,6 @@
-/* Copyright (C) 1995,1996,1998,1999,2000,2001, 2003, 2004, 2006, 2009, 2010, 
2011, 2012 Free Software Foundation, Inc.
- * 
+/* Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2003, 2004, 2006,
+ *   2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
+ *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
  * as published by the Free Software Foundation; either version 3 of
@@ -283,6 +284,10 @@ scm_make_smob (scm_t_bits tc)
 /* The GC kind used for SMOB types that provide a custom mark procedure.  */
 static int smob_gc_kind;
 
+/* Mark stack pointer and limit, used by `scm_gc_mark'.  */
+static scm_i_pthread_key_t current_mark_stack_pointer;
+static scm_i_pthread_key_t current_mark_stack_limit;
+
 
 /* The generic SMOB mark procedure that gets called for SMOBs allocated
    with smob_gc_kind.  */
@@ -321,14 +326,14 @@ smob_mark (GC_word *addr, struct GC_ms_entry 
*mark_stack_ptr,
     {
       SCM obj;
 
-      SCM_I_CURRENT_THREAD->current_mark_stack_ptr = mark_stack_ptr;
-      SCM_I_CURRENT_THREAD->current_mark_stack_limit = mark_stack_limit;
+      scm_i_pthread_setspecific (current_mark_stack_pointer, mark_stack_ptr);
+      scm_i_pthread_setspecific (current_mark_stack_limit, mark_stack_limit);
 
       /* Invoke the SMOB's mark procedure, which will in turn invoke
-        `scm_gc_mark ()', which may modify `current_mark_stack_ptr'.  */
+        `scm_gc_mark', which may modify `current_mark_stack_pointer'.  */
       obj = scm_smobs[smobnum].mark (cell);
 
-      mark_stack_ptr = SCM_I_CURRENT_THREAD->current_mark_stack_ptr;
+      mark_stack_ptr = scm_i_pthread_getspecific (current_mark_stack_pointer);
 
       if (SCM_HEAP_OBJECT_P (obj))
        /* Mark the returned object.  */
@@ -336,42 +341,35 @@ smob_mark (GC_word *addr, struct GC_ms_entry 
*mark_stack_ptr,
                                           mark_stack_ptr,
                                           mark_stack_limit, NULL);
 
-      SCM_I_CURRENT_THREAD->current_mark_stack_limit = NULL;
-      SCM_I_CURRENT_THREAD->current_mark_stack_ptr = NULL;
+      scm_i_pthread_setspecific (current_mark_stack_pointer, NULL);
+      scm_i_pthread_setspecific (current_mark_stack_limit, NULL);
     }
 
   return mark_stack_ptr;
 
 }
 
-/* Mark object O.  We assume that this function is only called during the
-   mark phase, i.e., from within `smob_mark ()' or one of its
-   descendents.  */
+/* Mark object O.  We assume that this function is only called during the mark
+   phase, i.e., from within `smob_mark' or one of its descendants.  */
 void
 scm_gc_mark (SCM o)
 {
-#define CURRENT_MARK_PTR                                                \
-  ((struct GC_ms_entry *)(SCM_I_CURRENT_THREAD->current_mark_stack_ptr))
-#define CURRENT_MARK_LIMIT                                                \
-  ((struct GC_ms_entry *)(SCM_I_CURRENT_THREAD->current_mark_stack_limit))
-
   if (SCM_HEAP_OBJECT_P (o))
     {
-      /* At this point, the `current_mark_*' fields of the current thread
-        must be defined (they are set in `smob_mark ()').  */
-      register struct GC_ms_entry *mark_stack_ptr;
+      void *mark_stack_ptr, *mark_stack_limit;
 
-      if (!CURRENT_MARK_PTR)
+      mark_stack_ptr = scm_i_pthread_getspecific (current_mark_stack_pointer);
+      mark_stack_limit = scm_i_pthread_getspecific (current_mark_stack_limit);
+
+      if (mark_stack_ptr == NULL)
        /* The function was not called from a mark procedure.  */
        abort ();
 
       mark_stack_ptr = GC_MARK_AND_PUSH (SCM2PTR (o),
-                                        CURRENT_MARK_PTR, CURRENT_MARK_LIMIT,
+                                        mark_stack_ptr, mark_stack_limit,
                                         NULL);
-      SCM_I_CURRENT_THREAD->current_mark_stack_ptr = mark_stack_ptr;
+      scm_i_pthread_setspecific (current_mark_stack_pointer, mark_stack_ptr);
     }
-#undef CURRENT_MARK_PTR
-#undef CURRENT_MARK_LIMIT
 }
 
 
@@ -452,6 +450,9 @@ scm_smob_prehistory ()
 {
   long i;
 
+  scm_i_pthread_key_create (&current_mark_stack_pointer, NULL);
+  scm_i_pthread_key_create (&current_mark_stack_limit, NULL);
+
   smob_gc_kind = GC_new_kind (GC_new_free_list (),
                              GC_MAKE_PROC (GC_new_proc (smob_mark), 0),
                              0,
diff --git a/libguile/socket.c b/libguile/socket.c
index 2320414..7e735f4 100644
--- a/libguile/socket.c
+++ b/libguile/socket.c
@@ -1,5 +1,5 @@
 /* Copyright (C) 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005,
- *   2006, 2007, 2009, 2011, 2012 Free Software Foundation, Inc.
+ *   2006, 2007, 2009, 2011, 2012, 2013 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -25,26 +25,8 @@
 #endif
 
 #include <errno.h>
-#include <gmp.h>
 #include <verify.h>
 
-#include "libguile/_scm.h"
-#include "libguile/arrays.h"
-#include "libguile/feature.h"
-#include "libguile/fports.h"
-#include "libguile/strings.h"
-#include "libguile/vectors.h"
-#include "libguile/dynwind.h"
-#include "libguile/srfi-13.h"
-
-#include "libguile/validate.h"
-#include "libguile/socket.h"
-
-#ifdef __MINGW32__
-#include "win32-socket.h"
-#include <netdb.h>
-#endif
-
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
 #endif
@@ -55,9 +37,6 @@
 #include <unistd.h>
 #endif
 #include <sys/types.h>
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h>
-#else
 #include <sys/socket.h>
 #ifdef HAVE_UNIX_DOMAIN_SOCKETS
 #include <sys/un.h>
@@ -65,8 +44,27 @@
 #include <netinet/in.h>
 #include <netdb.h>
 #include <arpa/inet.h>
+
+#include <gmp.h>
+
+#include "libguile/_scm.h"
+#include "libguile/arrays.h"
+#include "libguile/feature.h"
+#include "libguile/fports.h"
+#include "libguile/strings.h"
+#include "libguile/vectors.h"
+#include "libguile/dynwind.h"
+#include "libguile/srfi-13.h"
+
+#include "libguile/validate.h"
+#include "libguile/socket.h"
+
+#if SCM_ENABLE_DEPRECATED == 1
+# include "libguile/deprecation.h"
 #endif
 
+
+
 #if defined (HAVE_UNIX_DOMAIN_SOCKETS) && !defined (SUN_LEN)
 #define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) \
                      + strlen ((ptr)->sun_path))
@@ -512,6 +510,7 @@ SCM_DEFINE (scm_getsockopt, "getsockopt", 3, 0, 0,
            "@defvarx SO_OOBINLINE\n"
            "@defvarx SO_NO_CHECK\n"
            "@defvarx SO_PRIORITY\n"
+           "@defvarx SO_REUSEPORT\n"
            "The value returned is an integer.\n"
            "@end defvar\n"
            "\n"
@@ -610,6 +609,7 @@ SCM_DEFINE (scm_setsockopt, "setsockopt", 4, 0, 0,
            "@defvarx SO_OOBINLINE\n"
            "@defvarx SO_NO_CHECK\n"
            "@defvarx SO_PRIORITY\n"
+           "@defvarx SO_REUSEPORT\n"
            "@var{value} is an integer.\n"
            "@end defvar\n"
            "\n"
@@ -1767,6 +1767,9 @@ scm_init_socket ()
 #ifdef SO_LINGER
   scm_c_define ("SO_LINGER", scm_from_int (SO_LINGER));
 #endif
+#ifdef SO_REUSEPORT                              /* new in Linux 3.9 */
+  scm_c_define ("SO_REUSEPORT", scm_from_int (SO_REUSEPORT));
+#endif
 
   /* recv/send options.  */
 #ifdef MSG_DONTWAIT
@@ -1782,10 +1785,6 @@ scm_init_socket ()
   scm_c_define ("MSG_DONTROUTE", scm_from_int (MSG_DONTROUTE));
 #endif
 
-#ifdef __MINGW32__
-  scm_i_init_socket_Win32 ();
-#endif
-
 #ifdef IP_ADD_MEMBERSHIP
   scm_c_define ("IP_ADD_MEMBERSHIP", scm_from_int (IP_ADD_MEMBERSHIP));
   scm_c_define ("IP_DROP_MEMBERSHIP", scm_from_int (IP_DROP_MEMBERSHIP));
diff --git a/libguile/srfi-13.c b/libguile/srfi-13.c
index 97c5a1d..4e5d572 100644
--- a/libguile/srfi-13.c
+++ b/libguile/srfi-13.c
@@ -384,7 +384,7 @@ SCM_DEFINE (scm_string_join, "string-join", 1, 2, 0,
            "@item infix\n"
            "Insert the separator between list elements.  An empty string\n"
            "will produce an empty list.\n"
-           "@item string-infix\n"
+           "@item strict-infix\n"
            "Like @code{infix}, but will raise an error if given the empty\n"
            "list.\n"
            "@item suffix\n"
@@ -394,91 +394,85 @@ SCM_DEFINE (scm_string_join, "string-join", 1, 2, 0,
            "@end table")
 #define FUNC_NAME s_scm_string_join
 {
-#define GRAM_INFIX        0
-#define GRAM_STRICT_INFIX 1
-#define GRAM_SUFFIX       2
-#define GRAM_PREFIX       3
-  SCM tmp;
-  SCM result;
-  int gram = GRAM_INFIX;
-  size_t del_len = 0;
-  long strings = scm_ilength (ls);
+  SCM append_list = SCM_EOL;
+  long list_len = scm_ilength (ls);
+  size_t delimiter_len = 0;
 
   /* Validate the string list.  */
-  if (strings < 0)
+  if (list_len < 0)
     SCM_WRONG_TYPE_ARG (1, ls);
 
   /* Validate the delimiter and record its length.  */
   if (SCM_UNBNDP (delimiter))
     {
       delimiter = scm_from_locale_string (" ");
-      del_len = 1;
+      delimiter_len = 1;
     }
   else
     {
       SCM_VALIDATE_STRING (2, delimiter);
-      del_len = scm_i_string_length (delimiter);
+      delimiter_len = scm_i_string_length (delimiter);
     }
 
-  /* Validate the grammar symbol and remember the grammar.  */
+  /* Validate the grammar symbol.  */
   if (SCM_UNBNDP (grammar))
-    gram = GRAM_INFIX;
-  else if (scm_is_eq (grammar, scm_sym_infix))
-    gram = GRAM_INFIX;
-  else if (scm_is_eq (grammar, scm_sym_strict_infix))
-    gram = GRAM_STRICT_INFIX;
-  else if (scm_is_eq (grammar, scm_sym_suffix))
-    gram = GRAM_SUFFIX;
-  else if (scm_is_eq (grammar, scm_sym_prefix))
-    gram = GRAM_PREFIX;
-  else
+    grammar = scm_sym_infix;
+  else if (!(scm_is_eq (grammar, scm_sym_infix)
+             || scm_is_eq (grammar, scm_sym_strict_infix)
+             || scm_is_eq (grammar, scm_sym_suffix)
+             || scm_is_eq (grammar, scm_sym_prefix)))
     SCM_WRONG_TYPE_ARG (3, grammar);
 
-  /* Check grammar constraints.  */
-  if (strings == 0 && gram == GRAM_STRICT_INFIX)
-    SCM_MISC_ERROR ("strict-infix grammar requires non-empty list",
-                   SCM_EOL);
+  if (list_len == 0)
+    {
+      if (scm_is_eq (grammar, scm_sym_strict_infix))
+        SCM_MISC_ERROR ("strict-infix grammar requires non-empty list",
+                        SCM_EOL);
+      else
+        /* Handle empty lists specially */
+        append_list = SCM_EOL;
+    }
+  else if (delimiter_len == 0)
+    /* Handle empty delimiters specially */
+    append_list = ls;
+  else
+    {
+      SCM *last_cdr_p = &append_list;
 
-  result = scm_i_make_string (0, NULL, 0);
+#define ADD_TO_APPEND_LIST(x)                   \
+      ((*last_cdr_p = scm_list_1 (x)),          \
+       (last_cdr_p = SCM_CDRLOC (*last_cdr_p)))
 
-  tmp = ls;
-  switch (gram)
-    {
-    case GRAM_INFIX:
-    case GRAM_STRICT_INFIX:
-      while (scm_is_pair (tmp))
-       {
-         result = scm_string_append (scm_list_2 (result, SCM_CAR (tmp)));
-         if (!scm_is_null (SCM_CDR (tmp)) && del_len > 0)
-           result = scm_string_append (scm_list_2 (result, delimiter));
-         tmp = SCM_CDR (tmp);
-       }
-      break;
-    case GRAM_SUFFIX:
-      while (scm_is_pair (tmp))
-       {
-         result = scm_string_append (scm_list_2 (result, SCM_CAR (tmp)));
-         if (del_len > 0)
-           result = scm_string_append (scm_list_2 (result, delimiter));
-         tmp = SCM_CDR (tmp);
-       }
-      break;
-    case GRAM_PREFIX:
-      while (scm_is_pair (tmp))
-       {
-         if (del_len > 0)
-           result = scm_string_append (scm_list_2 (result, delimiter));
-         result = scm_string_append (scm_list_2 (result, SCM_CAR (tmp)));
-         tmp = SCM_CDR (tmp);
-       }
-      break;
+      /* Build a list of strings to pass to 'string-append'.
+         Here we assume that 'ls' has at least one element. */
+
+      /* If using the 'prefix' grammar, start with the delimiter. */
+      if (scm_is_eq (grammar, scm_sym_prefix))
+        ADD_TO_APPEND_LIST (delimiter);
+
+      /* Handle the first element of 'ls' specially, so that in the loop
+         that follows we can unconditionally insert the delimiter before
+         every remaining element. */
+      ADD_TO_APPEND_LIST (SCM_CAR (ls));
+      ls = SCM_CDR (ls);
+
+      /* Insert the delimiter before every remaining element. */
+      while (scm_is_pair (ls))
+        {
+          ADD_TO_APPEND_LIST (delimiter);
+          ADD_TO_APPEND_LIST (SCM_CAR (ls));
+          ls = SCM_CDR (ls);
+        }
+
+      /* If using the 'suffix' grammar, add the delimiter to the end. */
+      if (scm_is_eq (grammar, scm_sym_suffix))
+        ADD_TO_APPEND_LIST (delimiter);
+
+#undef ADD_TO_APPEND_LIST
     }
 
-  return result;
-#undef GRAM_INFIX
-#undef GRAM_STRICT_INFIX
-#undef GRAM_SUFFIX
-#undef GRAM_PREFIX
+  /* Construct the final result. */
+  return scm_string_append (append_list);
 }
 #undef FUNC_NAME
 
diff --git a/libguile/srfi-14.i.c b/libguile/srfi-14.i.c
index f59a807..42a1c2c 100644
--- a/libguile/srfi-14.i.c
+++ b/libguile/srfi-14.i.c
@@ -4790,7 +4790,7 @@ scm_t_char_range cs_graphic_ranges[] = {
   ,
   {0x2090, 0x209c}
   ,
-  {0x20a0, 0x20b9}
+  {0x20a0, 0x20ba}
   ,
   {0x20d0, 0x20f0}
   ,
@@ -5906,7 +5906,7 @@ scm_t_char_range cs_printing_ranges[] = {
   ,
   {0x2090, 0x209c}
   ,
-  {0x20a0, 0x20b9}
+  {0x20a0, 0x20ba}
   ,
   {0x20d0, 0x20f0}
   ,
@@ -6897,7 +6897,7 @@ scm_t_char_range cs_symbol_ranges[] = {
   ,
   {0x208a, 0x208c}
   ,
-  {0x20a0, 0x20b9}
+  {0x20a0, 0x20ba}
   ,
   {0x2100, 0x2101}
   ,
@@ -7728,7 +7728,7 @@ scm_t_char_range cs_designated_ranges[] = {
   ,
   {0x2090, 0x209c}
   ,
-  {0x20a0, 0x20b9}
+  {0x20a0, 0x20ba}
   ,
   {0x20d0, 0x20f0}
   ,
diff --git a/libguile/stime.c b/libguile/stime.c
index 7fdbba9..78539d9 100644
--- a/libguile/stime.c
+++ b/libguile/stime.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2003, 2004, 2005, 2006, 
2007, 2008, 2009, 2011 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2003, 2004, 2005, 2006, 
2007, 2008, 2009, 2011, 2013 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -68,29 +68,14 @@
 # include <time.h>
 #endif
 
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#ifdef HAVE_STRING_H
+#include <sys/types.h>
 #include <string.h>
-#endif
-
-#ifdef HAVE_SYS_TIMES_H
-# include <sys/times.h>
-#endif
+#include <sys/times.h>
 
 #ifdef HAVE_SYS_TIMEB_H
 # include <sys/timeb.h>
 #endif
 
-#ifndef tzname /* For SGI.  */
-extern char *tzname[]; /* RS6000 and others reject char **tzname.  */
-#endif
-#if defined (__MINGW32__)
-# define tzname _tzname
-#endif
-
 #if ! HAVE_DECL_STRPTIME
 extern char *strptime ();
 #endif
@@ -177,7 +162,6 @@ get_internal_real_time_gettimeofday (void)
 #endif
 
 
-#if defined HAVE_TIMES
 static long ticks_per_second;
 
 static long
@@ -188,7 +172,6 @@ get_internal_run_time_times (void)
   return (time_buffer.tms_utime + time_buffer.tms_stime)
     * TIME_UNITS_PER_SECOND / ticks_per_second;
 }
-#endif
 
 static timet fallback_real_time_base;
 static long
@@ -210,7 +193,6 @@ SCM_DEFINE (scm_get_internal_real_time, 
"get-internal-real-time", 0, 0, 0,
 #undef FUNC_NAME
 
 
-#ifdef HAVE_TIMES
 SCM_DEFINE (scm_times, "times", 0, 0, 0,
             (void),
            "Return an object with information about real and processor\n"
@@ -261,7 +243,6 @@ SCM_DEFINE (scm_times, "times", 0, 0, 0,
   return result;
 }
 #undef FUNC_NAME
-#endif /* HAVE_TIMES */
 
 long
 scm_c_get_internal_run_time (void)
@@ -876,7 +857,6 @@ scm_init_stime()
 
   /* Init ticks_per_second for scm_times, and use times(2)-based
      run-time timer if needed. */
-#ifdef HAVE_TIMES
 #ifdef _SC_CLK_TCK
   ticks_per_second = sysconf (_SC_CLK_TCK);
 #else
@@ -884,7 +864,6 @@ scm_init_stime()
 #endif
   if (!get_internal_run_time)
     get_internal_run_time = get_internal_run_time_times;
-#endif
 
   if (!get_internal_real_time)
     /* No POSIX timers, gettimeofday doesn't work... badness!  */
@@ -893,10 +872,6 @@ scm_init_stime()
       get_internal_real_time = get_internal_real_time_fallback;
     }
 
-  /* If we don't have a run-time timer, use real-time.  */
-  if (!get_internal_run_time)
-    get_internal_run_time = get_internal_real_time;
-
   scm_add_feature ("current-time");
 #include "libguile/stime.x"
 }
diff --git a/libguile/strings.c b/libguile/strings.c
index 85a6c48..fa97a00 100644
--- a/libguile/strings.c
+++ b/libguile/strings.c
@@ -29,6 +29,7 @@
 #include <uninorm.h>
 #include <unistr.h>
 #include <uniconv.h>
+#include <c-strcase.h>
 
 #include "striconveh.h"
 
@@ -36,6 +37,8 @@
 #include "libguile/chars.h"
 #include "libguile/root.h"
 #include "libguile/strings.h"
+#include "libguile/ports.h"
+#include "libguile/ports-internal.h"
 #include "libguile/error.h"
 #include "libguile/generalized-vectors.h"
 #include "libguile/deprecation.h"
@@ -1401,7 +1404,8 @@ SCM_DEFINE (scm_string_append, "string-append", 0, 0, 1,
 #define FUNC_NAME s_scm_string_append
 {
   SCM res;
-  size_t len = 0;
+  size_t total = 0;
+  size_t len;
   int wide = 0;
   SCM l, s;
   size_t i;
@@ -1416,15 +1420,18 @@ SCM_DEFINE (scm_string_append, "string-append", 0, 0, 1,
     {
       s = SCM_CAR (l);
       SCM_VALIDATE_STRING (SCM_ARGn, s);
-      len += scm_i_string_length (s);
+      len = scm_i_string_length (s);
+      if (((size_t) -1) - total < len)
+        scm_num_overflow (s_scm_string_append);
+      total += len;
       if (!scm_i_is_narrow_string (s))
         wide = 1;
     }
   data.narrow = NULL;
   if (!wide)
-    res = scm_i_make_string (len, &data.narrow, 0);
+    res = scm_i_make_string (total, &data.narrow, 0);
   else
-    res = scm_i_make_wide_string (len, &data.wide, 0);
+    res = scm_i_make_wide_string (total, &data.wide, 0);
 
   for (l = args; !scm_is_null (l); l = SCM_CDR (l))
     {
@@ -1432,6 +1439,8 @@ SCM_DEFINE (scm_string_append, "string-append", 0, 0, 1,
       s = SCM_CAR (l);
       SCM_VALIDATE_STRING (SCM_ARGn, s);
       len = scm_i_string_length (s);
+      if (len > total)
+        SCM_MISC_ERROR ("list changed during string-append", SCM_EOL);
       if (!wide)
         {
           memcpy (data.narrow, scm_i_string_chars (s), len);
@@ -1441,16 +1450,20 @@ SCM_DEFINE (scm_string_append, "string-append", 0, 0, 1,
         {
           if (scm_i_is_narrow_string (s))
             {
-              for (i = 0; i < scm_i_string_length (s); i++)
-                data.wide[i] = (unsigned char) scm_i_string_chars (s)[i];
+              const char *src = scm_i_string_chars (s);
+              for (i = 0; i < len; i++)
+                data.wide[i] = (unsigned char) src[i];
             }
           else
             u32_cpy ((scm_t_uint32 *) data.wide,
                      (scm_t_uint32 *) scm_i_string_wide_chars (s), len);
           data.wide += len;
         }
+      total -= len;
       scm_remember_upto_here_1 (s);
     }
+  if (total != 0)
+    SCM_MISC_ERROR ("list changed during string-append", SCM_EOL);
   return res;
 }
 #undef FUNC_NAME
@@ -1524,9 +1537,9 @@ scm_from_stringn (const char *str, size_t len, const char 
*encoding,
   if (len == (size_t) -1)
     len = strlen (str);
 
-  if (strcmp (encoding, "ISO-8859-1") == 0 || len == 0)
+  if (c_strcasecmp (encoding, "ISO-8859-1") == 0 || len == 0)
     return scm_from_latin1_stringn (str, len);
-  else if (strcmp (encoding, "UTF-8") == 0
+  else if (c_strcasecmp (encoding, "UTF-8") == 0
            && handler == SCM_FAILED_CONVERSION_ERROR)
     return scm_from_utf8_stringn (str, len);
 
@@ -1722,10 +1735,11 @@ SCM
 scm_from_port_stringn (const char *str, size_t len, SCM port)
 {
   scm_t_port *pt = SCM_PTAB_ENTRY (port);
+  scm_t_port_internal *pti = SCM_PORT_GET_INTERNAL (port);
 
-  if (pt->encoding_mode == SCM_PORT_ENCODING_MODE_LATIN1)
+  if (pti->encoding_mode == SCM_PORT_ENCODING_MODE_LATIN1)
     return scm_from_latin1_stringn (str, len);
-  else if (pt->encoding_mode == SCM_PORT_ENCODING_MODE_UTF8
+  else if (pti->encoding_mode == SCM_PORT_ENCODING_MODE_UTF8
            && pt->ilseq_handler == SCM_FAILED_CONVERSION_ERROR)
     return scm_from_utf8_stringn (str, len);
   else
@@ -2127,11 +2141,12 @@ char *
 scm_to_port_stringn (SCM str, size_t *lenp, SCM port)
 {
   scm_t_port *pt = SCM_PTAB_ENTRY (port);
+  scm_t_port_internal *pti = SCM_PORT_GET_INTERNAL (port);
 
-  if (pt->encoding_mode == SCM_PORT_ENCODING_MODE_LATIN1
+  if (pti->encoding_mode == SCM_PORT_ENCODING_MODE_LATIN1
       && pt->ilseq_handler == SCM_FAILED_CONVERSION_ERROR)
     return scm_to_latin1_stringn (str, lenp);
-  else if (pt->encoding_mode == SCM_PORT_ENCODING_MODE_UTF8)
+  else if (pti->encoding_mode == SCM_PORT_ENCODING_MODE_UTF8)
     return scm_to_utf8_stringn (str, lenp);
   else
     return scm_to_stringn (str, lenp, pt->encoding, pt->ilseq_handler);
@@ -2170,7 +2185,8 @@ scm_to_stringn (SCM str, size_t *lenp, const char 
*encoding,
                         "string contains #\\nul character: ~S",
                         scm_list_1 (str));
 
-  if (scm_i_is_narrow_string (str) && strcmp (encoding, "ISO-8859-1") == 0)
+  if (scm_i_is_narrow_string (str)
+      && c_strcasecmp (encoding, "ISO-8859-1") == 0)
     {
       /* If using native Latin-1 encoding, just copy the string
          contents.  */
diff --git a/libguile/strports.c b/libguile/strports.c
index 425b089..40f656e 100644
--- a/libguile/strports.c
+++ b/libguile/strports.c
@@ -464,13 +464,16 @@ SCM_DEFINE (scm_eval_string_in_module, "eval-string", 1, 
1, 0,
             "procedure returns.")
 #define FUNC_NAME s_scm_eval_string_in_module
 {
-  static SCM eval_string = SCM_BOOL_F, k_module = SCM_BOOL_F;
+  static SCM eval_string = SCM_UNDEFINED, k_module = SCM_UNDEFINED;
+  static scm_i_pthread_mutex_t init_mutex = SCM_I_PTHREAD_MUTEX_INITIALIZER;
 
-  if (scm_is_false (eval_string))
+  scm_i_scm_pthread_mutex_lock (&init_mutex);
+  if (SCM_UNBNDP (eval_string))
     {
-      eval_string = scm_c_public_lookup ("ice-9 eval-string", "eval-string");
+      eval_string = scm_c_public_variable ("ice-9 eval-string", "eval-string");
       k_module = scm_from_locale_keyword ("module");
     }
+  scm_i_pthread_mutex_unlock (&init_mutex);
   
   if (SCM_UNBNDP (module))
     module = scm_current_module ();
diff --git a/libguile/struct.c b/libguile/struct.c
index db79e79..c7f410b 100644
--- a/libguile/struct.c
+++ b/libguile/struct.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1996,1997,1998,1999,2000,2001, 2003, 2004, 2006, 2007, 2008, 
2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
+/* Copyright (C) 1996,1997,1998,1999,2000,2001, 2003, 2004, 2006, 2007,
+ *   2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -152,8 +153,9 @@ SCM_DEFINE (scm_make_struct_layout, "make-struct-layout", 
1, 0, 0,
 #undef FUNC_NAME
 
 
-/* Check whether VTABLE instances have a simple layout (i.e., either only "pr"
-   or only "pw" fields) and update its flags accordingly.  */
+/* Check whether VTABLE instances have a simple layout (i.e., either
+   only "pr" or only "pw" fields and no tail array) and update its flags
+   accordingly.  */
 static void
 set_vtable_layout_flags (SCM vtable)
 {
@@ -179,13 +181,11 @@ set_vtable_layout_flags (SCM vtable)
        switch (c_layout[field + 1])
          {
          case 'w':
-         case 'W':
            if (field == 0)
              flags |= SCM_VTABLE_FLAG_SIMPLE_RW;
            break;
 
          case 'r':
-         case 'R':
            flags &= ~SCM_VTABLE_FLAG_SIMPLE_RW;
            break;
 
diff --git a/libguile/struct.h b/libguile/struct.h
index 97b6768..0aecfb9 100644
--- a/libguile/struct.h
+++ b/libguile/struct.h
@@ -3,7 +3,7 @@
 #ifndef SCM_STRUCT_H
 #define SCM_STRUCT_H
 
-/* Copyright (C) 1995,1997,1999,2000,2001, 2006, 2007, 2008, 2009, 2010, 2011, 
2012 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1997,1999,2000,2001, 2006, 2007, 2008, 2009, 2010, 2011, 
2012, 2013 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -108,8 +108,8 @@
 #define SCM_VTABLE_FLAG_APPLICABLE (1L << 3) /* instances of this vtable are 
applicable? */
 #define SCM_VTABLE_FLAG_SETTER_VTABLE (1L << 4) /* instances of this vtable 
are applicable-with-setter vtables? */
 #define SCM_VTABLE_FLAG_SETTER (1L << 5) /* instances of this vtable are 
applicable-with-setters? */
-#define SCM_VTABLE_FLAG_SIMPLE (1L << 6) /* instances of this vtable have only 
"p" fields */
-#define SCM_VTABLE_FLAG_SIMPLE_RW (1L << 7) /* instances of this vtable have 
only "pw" fields */
+#define SCM_VTABLE_FLAG_SIMPLE (1L << 6) /* instances of this vtable have only 
"p" fields and no tail array*/
+#define SCM_VTABLE_FLAG_SIMPLE_RW (1L << 7) /* instances of this vtable have 
only "pw" fields and no tail array */
 #define SCM_VTABLE_FLAG_RESERVED_0 (1L << 8)
 #define SCM_VTABLE_FLAG_RESERVED_1 (1L << 9)
 #define SCM_VTABLE_FLAG_RESERVED_2 (1L << 10)
diff --git a/libguile/texi-fragments-to-docstrings 
b/libguile/texi-fragments-to-docstrings
new file mode 100644
index 0000000..b72390b
--- /dev/null
+++ b/libguile/texi-fragments-to-docstrings
@@ -0,0 +1,55 @@
+;;; -*- mode: scheme; coding: utf-8; -*-
+;;;
+;;; Copyright (C) 2013 Free Software Foundation, Inc.
+;;;
+;;; This library is free software; you can redistribute it and/or
+;;; modify it under the terms of the GNU Lesser General Public
+;;; License as published by the Free Software Foundation; either
+;;; version 3 of the License, or (at your option) any later version.
+;;;
+;;; This library is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;;; Lesser General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU Lesser General Public
+;;; License along with this library; if not, write to the Free Software
+;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
USA
+
+
+;;;
+;;; Read Texinfo fragments from stdin (docstrings of Guile's primitives
+;;; in the format of `guile-procedures.texi'), and write to stdout a
+;;; textual rendering thereof.  The output preserves page breaks (^L)
+;;; found in the input, as per the Guile Documentation Format
+;;; version 2---see (ice-9 documentation).
+;;;
+
+(use-modules (texinfo)
+             (texinfo plain-text)
+             (srfi srfi-1)
+             (ice-9 match)
+             (rnrs io ports))
+
+(define (docstring-fragments->strings str)
+  "Return the list resulting from the split of STR at each page
+break (^L)"
+  (string-tokenize str (char-set-complement (char-set #\page))))
+
+(match (command-line)
+  ((_ texi-file)
+   (let* ((fragments (remove (compose string-null? string-trim-both)
+                             (call-with-input-file texi-file
+                               (compose docstring-fragments->strings
+                                        get-string-all))))
+          (stexi     (map texi-fragment->stexi fragments)))
+     (format #t "Produced by GNU Guile ~a from `~a'.~%~%"
+             (version) texi-file)
+     (for-each (lambda (stexi)
+                 (display #\page)
+                 (display (stexi->plain-text stexi)))
+               stexi)))
+  ((command args ...)
+   (format (current-error-port) "invalid arguments: ~s~%" args)
+   (format (current-error-port) "Usage: ~a TEXINFO-FILE~%" command)
+   (exit 1)))
diff --git a/libguile/threads.c b/libguile/threads.c
index 61fc43e..ef771dc 100644
--- a/libguile/threads.c
+++ b/libguile/threads.c
@@ -1,5 +1,5 @@
 /* Copyright (C) 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004,
- *   2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
+ *   2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
  *   Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
@@ -45,6 +45,8 @@
 # include <pthread_np.h>
 #endif
 
+#include <sys/select.h>
+
 #include <assert.h>
 #include <fcntl.h>
 #include <nproc.h>
@@ -1057,7 +1059,10 @@ SCM_DEFINE (scm_call_with_new_thread, 
"call-with-new-thread", 1, 1, 0,
       errno = err;
       scm_syserror (NULL);
     }
-  scm_i_scm_pthread_cond_wait (&data.cond, &data.mutex);
+
+  while (scm_is_false (data.thread))
+    scm_i_scm_pthread_cond_wait (&data.cond, &data.mutex);
+
   scm_i_pthread_mutex_unlock (&data.mutex);
 
   return data.thread;
@@ -1134,7 +1139,10 @@ scm_spawn_thread (scm_t_catch_body body, void *body_data,
       errno = err;
       scm_syserror (NULL);
     }
-  scm_i_scm_pthread_cond_wait (&data.cond, &data.mutex);
+
+  while (scm_is_false (data.thread))
+    scm_i_scm_pthread_cond_wait (&data.cond, &data.mutex);
+
   scm_i_pthread_mutex_unlock (&data.mutex);
 
   assert (SCM_I_IS_THREAD (data.thread));
@@ -1867,9 +1875,9 @@ SCM_DEFINE (scm_condition_variable_p, 
"condition-variable?", 1, 0, 0,
 struct select_args
 {
   int             nfds;
-  SELECT_TYPE    *read_fds;
-  SELECT_TYPE    *write_fds;
-  SELECT_TYPE    *except_fds;
+  fd_set         *read_fds;
+  fd_set         *write_fds;
+  fd_set         *except_fds;
   struct timeval *timeout;
 
   int             result;
@@ -1892,11 +1900,19 @@ do_std_select (void *args)
   return NULL;
 }
 
+#if !SCM_HAVE_SYS_SELECT_H
+static int scm_std_select (int nfds,
+                           fd_set *readfds,
+                           fd_set *writefds,
+                           fd_set *exceptfds,
+                           struct timeval *timeout);
+#endif
+
 int
 scm_std_select (int nfds,
-               SELECT_TYPE *readfds,
-               SELECT_TYPE *writefds,
-               SELECT_TYPE *exceptfds,
+               fd_set *readfds,
+               fd_set *writefds,
+               fd_set *exceptfds,
                struct timeval *timeout)
 {
   fd_set my_readfds;
diff --git a/libguile/threads.h b/libguile/threads.h
index 3030f6f..147e36d 100644
--- a/libguile/threads.h
+++ b/libguile/threads.h
@@ -3,7 +3,8 @@
 #ifndef SCM_THREADS_H
 #define SCM_THREADS_H
 
-/* Copyright (C) 1996,1997,1998,2000,2001, 2002, 2003, 2004, 2006, 2007, 2008, 
2009, 2011, 2012 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2006,
+ *   2007, 2008, 2009, 2011, 2012, 2013 Free Software Foundation, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -71,8 +72,8 @@ typedef struct scm_i_thread {
   scm_i_pthread_cond_t sleep_cond;
   int sleep_fd, sleep_pipe[2];
 
-  /* Information about the Boehm-GC mark stack during the mark phase.  This
-     is used by `scm_gc_mark ()'.  */
+  /* XXX: These two fields used to hold information about the BDW-GC
+     mark stack during the mark phase.  They are no longer used.  */
   void *current_mark_stack_ptr;
   void *current_mark_stack_limit;
 
diff --git a/libguile/uniform.c b/libguile/uniform.c
index d3ecb1b..a58242d 100644
--- a/libguile/uniform.c
+++ b/libguile/uniform.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995,1996,1997,1998,2000,2001,2002,2003,2004, 2005, 2006, 
2009, 2010 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1997,1998,2000,2001,2002,2003,2004, 2005, 2006, 
2009, 2010, 2013 Free Software Foundation, Inc.
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -193,7 +193,7 @@ SCM_DEFINE (scm_uniform_vector_to_list, 
"uniform-vector->list", 1, 0, 0,
 {
   if (!scm_is_uniform_vector (uvec))
     scm_wrong_type_arg_msg (FUNC_NAME, SCM_ARG1, uvec, "uniform vector");
-  return scm_generalized_vector_to_list (uvec);
+  return scm_array_to_list (uvec);
 }
 #undef FUNC_NAME
 
diff --git a/libguile/vm-engine.c b/libguile/vm-engine.c
index 44687e2..3def7a3 100644
--- a/libguile/vm-engine.c
+++ b/libguile/vm-engine.c
@@ -519,7 +519,6 @@ VM_NAME (SCM vm, SCM program, SCM *argv, int nargs)
 #undef VM_CHECK_UNDERFLOW
 #undef VM_DEFINE_OP
 #undef VM_INSTRUCTION_TO_LABEL
-#undef VM_USE_HOOKS
 
 
 
@@ -581,6 +580,11 @@ VM_NAME (SCM vm, SCM program, SCM *argv, int nargs)
     vp->sp = fp - 1 + n;                                            \
   } while (0)
 
+/* Compute the number of locals in the frame.  This is equal to the
+   number of actual arguments when a function is first called.  */
+#define FRAME_LOCALS_COUNT()                                        \
+  (vp->sp + 1 - fp)
+
 /* Restore registers after returning from a frame.  */
 #define RESTORE_FRAME()                                             \
   do {                                                              \
@@ -660,8 +664,7 @@ VM_NAME (SCM vm, SCM program, SCM *argv, int nargs)
     fp[-1] = rtl_apply;                                 \
     fp[0] = rtl_values;                                 \
     fp[1] = vals;                                       \
-    nargs = 2;                                          \
-    RESET_FRAME (nargs);                                \
+    RESET_FRAME (2);                                    \
     ip = (scm_t_uint32 *) rtl_apply_code;               \
     goto op_apply;                                      \
   } while (0)
@@ -669,7 +672,7 @@ VM_NAME (SCM vm, SCM program, SCM *argv, int nargs)
 #define BR_NARGS(rel)                           \
   scm_t_uint16 expected;                        \
   SCM_UNPACK_RTL_24 (op, expected);             \
-  if (nargs rel expected)                       \
+  if (FRAME_LOCALS_COUNT() rel expected)        \
     {                                           \
       scm_t_int32 offset = ip[1];               \
       offset >>= 8; /* Sign-extending shift. */ \
@@ -803,10 +806,6 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t nargs_)
   /* Current opcode: A cache of *ip.  */
   register scm_t_uint32 op;
 
-  /* Number of arguments passed to a function.  When we get native
-     compilation, this will be part of a the calling convention.  */
-  scm_t_uint32 nargs = 0;
-
   /* Cached variables. */
   struct scm_vm *vp = SCM_VM_DATA (vm);
   SCM *stack_limit = vp->stack_limit;  /* stack limit address */
@@ -845,7 +844,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t nargs_)
          to pull all our state back from the ip/fp/sp.
       */
       CACHE_REGISTER ();
-      ABORT_CONTINUATION_HOOK (fp, vp->sp + 1 - fp);
+      ABORT_CONTINUATION_HOOK (fp, FRAME_LOCALS_COUNT());
       NEXT (0);
     }
 
@@ -862,15 +861,14 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
        continuation, 4 + nargs for the procedure application, and 4 for
        setting up a new frame.  */
     base = vp->sp + 1;
-    nargs = nargs_;
-    CHECK_OVERFLOW (vp->sp + 4 + 4 + nargs + 4);
+    CHECK_OVERFLOW (vp->sp + 4 + 4 + nargs_ + 4);
 
     /* Since it's possible to receive the arguments on the stack itself,
        and indeed the regular VM invokes us that way, shuffle up the
        arguments first.  */
     {
       int i;
-      for (i = nargs - 1; i >= 0; i--)
+      for (i = nargs_ - 1; i >= 0; i--)
         base[8 + i] = argv[i];
     }
 
@@ -891,7 +889,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t nargs_)
     base[6] = SCM_PACK (ip); /* ra */
     base[7] = program;
     fp = vp->fp = &base[8];
-    RESET_FRAME (nargs);
+    RESET_FRAME (nargs_);
   }
 
  apply:
@@ -907,13 +905,14 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
         }
       if (SCM_HAS_TYP7 (proc, scm_tc7_smob) && SCM_SMOB_APPLICABLE_P (proc))
         {
-          scm_t_uint32 n = nargs;
+          scm_t_uint32 n = FRAME_LOCALS_COUNT();
 
           /* Shuffle args up, place smob in local 0. */
+          CHECK_OVERFLOW (vp->sp + 1);
+          vp->sp++;
           while (n--)
             LOCAL_SET (n + 1, LOCAL_REF (n));
           LOCAL_SET (0, proc);
-          nargs++;
 
           fp[-1] = SCM_SMOB_DESCRIPTOR (proc).apply_trampoline;
           continue;
@@ -925,7 +924,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t nargs_)
       SCM ret;
       SYNC_ALL ();
 
-      ret = VM_NAME (vm, fp[-1], fp, nargs);
+      ret = VM_NAME (vm, fp[-1], fp, FRAME_LOCALS_COUNT ());
 
       if (SCM_UNLIKELY (SCM_VALUESP (ret)))
         RETURN_VALUE_LIST (scm_struct_ref (ret, SCM_INUM0));
@@ -975,7 +974,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t nargs_)
       SYNC_BEFORE_GC();
 
       base = fp + 4;
-      n = vp->sp + 1 - base;
+      n = FRAME_LOCALS_COUNT ();
       while (n--)
         ret = scm_cons (base[n], ret);
 
@@ -1000,7 +999,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t nargs_)
    */
   VM_DEFINE_OP (2, call, "call", OP3 (U8_U24, X8_U24, X8_R24))
     {
-      scm_t_uint32 from, proc, n;
+      scm_t_uint32 from, proc, nargs, n;
       SCM *old_fp = fp;
 
       SCM_UNPACK_RTL_24 (op, from);
@@ -1032,9 +1031,8 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
   /* call/values from:24 _:8 proc:24
    *
    * Call a procedure, with the values already pushed above a call frame
-   * at FROM.  The stack pointer is used to set the nargs.  This
-   * instruction is used to handle MV returns in the case that we can't
-   * inline the handler.
+   * at FROM.  This instruction is used to handle MV returns in the case
+   * that we can't inline the handler.
    *
    * As with `call', the next instruction after the call/values will be
    * the MVRA, and the word after that instruction is the RA.
@@ -1051,10 +1049,9 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
 
       fp = vp->fp = old_fp + from + 4;
       SCM_FRAME_SET_DYNAMIC_LINK (fp, old_fp);
-      SCM_FRAME_SET_RTL_MV_RETURN_ADDRESS (fp, ip + 2 + nargs);
-      SCM_FRAME_SET_RTL_RETURN_ADDRESS (fp, ip + 3 + nargs);
+      SCM_FRAME_SET_RTL_MV_RETURN_ADDRESS (fp, ip + 2);
+      SCM_FRAME_SET_RTL_RETURN_ADDRESS (fp, ip + 3);
       fp[-1] = old_fp[proc];
-      nargs = vp->sp - fp;
 
       PUSH_CONTINUATION_HOOK ();
       APPLY_HOOK ();
@@ -1073,7 +1070,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    */
   VM_DEFINE_OP (4, tail_call, "tail-call", OP2 (U8_U24, X8_U24))
     {
-      scm_t_uint32 proc;
+      scm_t_uint32 nargs, proc;
 
       SCM_UNPACK_RTL_24 (op, nargs);
       SCM_UNPACK_RTL_24 (ip[1], proc);
@@ -1110,12 +1107,13 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * Return a number of values from a call frame.  This opcode
    * corresponds to an application of `values' in tail position.  As
    * with tail calls, we expect that the NVALUES values have already
-   * been shuffled down to a contiguous array starting ast slot 0.
+   * been shuffled down to a contiguous array starting at slot 0.
    */
   VM_DEFINE_OP (6, return_values, "return/values", OP1 (U8_U24))
     {
+      scm_t_uint32 nargs;
       SCM_UNPACK_RTL_24 (op, nargs);
-      RESET_FRAME(nargs);
+      RESET_FRAME (nargs);
       fp[-1] = rtl_values;
       goto op_values;
     }
@@ -1127,21 +1125,20 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * Specialized call stubs
    */
 
-  /* subr-call nargs:12 ptr-idx:12
+  /* subr-call ptr-idx:24
    *
-   * Call a subr.  Fetch the foreign pointer from PTR-IDX, a free
-   * variable.  Return from the calling frame.  We assume that the
-   * arguments are on the stack from slot 0 to NARGS-1.  This instruction
-   * is part of the trampolines created in gsubr.c, and is not generated
-   * by the compiler.
+   * Call a subr, passing all locals in this frame as arguments.  Fetch
+   * the foreign pointer from PTR-IDX, a free variable.  Return from the
+   * calling frame.  This instruction is part of the trampolines
+   * created in gsubr.c, and is not generated by the compiler.
    */
-  VM_DEFINE_OP (7, subr_call, "subr-call", OP1 (U8_U12_U12))
+  VM_DEFINE_OP (7, subr_call, "subr-call", OP1 (U8_U24))
     {
-      scm_t_uint16 nargs, ptr_idx;
+      scm_t_uint32 ptr_idx;
       SCM pointer, ret;
       SCM (*subr)();
 
-      SCM_UNPACK_RTL_12_12 (op, nargs, ptr_idx);
+      SCM_UNPACK_RTL_24 (op, ptr_idx);
 
       pointer = FREE_VARIABLE_REF (ptr_idx);
       subr = SCM_POINTER_VALUE (pointer);
@@ -1149,7 +1146,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
       VM_HANDLE_INTERRUPTS;
       SYNC_IP ();
 
-      switch (nargs)
+      switch (FRAME_LOCALS_COUNT ())
         {
         case 0:
           ret = subr ();
@@ -1197,20 +1194,20 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
         RETURN_ONE_VALUE (ret);
     }
 
-  /* foreign-call nargs:8 cif-idx:8 ptr-idx:8
+  /* foreign-call cif-idx:12 ptr-idx:12
    *
-   * Call a subr.  Fetch the CIF and foreign pointer from CIF-IDX and
-   * PTR-IDX, both free variables.  Return from the calling frame.  We
-   * assume that the arguments are on the stack from slot 0 to NARGS-1.
-   * This instruction is part of the trampolines created by the FFI, and
-   * is not generated by the compiler.
+   * Call a foreign function.  Fetch the CIF and foreign pointer from
+   * CIF-IDX and PTR-IDX, both free variables.  Return from the calling
+   * frame.  Arguments are taken from the stack.  This instruction is
+   * part of the trampolines created by the FFI, and is not generated by
+   * the compiler.
    */
-  VM_DEFINE_OP (8, foreign_call, "foreign-call", OP1 (U8_U8_U8_U8))
+  VM_DEFINE_OP (8, foreign_call, "foreign-call", OP1 (U8_U12_U12))
     {
-      scm_t_uint8 cif_idx, ptr_idx;
+      scm_t_uint16 cif_idx, ptr_idx;
       SCM cif, pointer, ret;
 
-      SCM_UNPACK_RTL_8_8_8 (op, nargs, cif_idx, ptr_idx);
+      SCM_UNPACK_RTL_12_12 (op, cif_idx, ptr_idx);
 
       cif = FREE_VARIABLE_REF (cif_idx);
       pointer = FREE_VARIABLE_REF (ptr_idx);
@@ -1230,21 +1227,20 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
         RETURN_ONE_VALUE (ret);
     }
 
-  /* continuation-call nargs:24 _:8 contregs:24
+  /* continuation-call contregs:24
    *
-   * Return to a continuation, nonlocally.  The NARGS values are taken
-   * from the stack, from slots 0 to NARGS-1.  CONTREGS is a free variable
-   * containing the reified continuation.  This instruction is part of the
-   * implementation of undelimited continuations, and is not generated by
-   * the compiler.
+   * Return to a continuation, nonlocally.  The arguments to the
+   * continuation are taken from the stack.  CONTREGS is a free variable
+   * containing the reified continuation.  This instruction is part of
+   * the implementation of undelimited continuations, and is not
+   * generated by the compiler.
    */
-  VM_DEFINE_OP (9, continuation_call, "continuation-call", OP2 (U8_U24, 
X8_U24))
+  VM_DEFINE_OP (9, continuation_call, "continuation-call", OP1 (U8_U24))
     {
       SCM contregs;
       scm_t_uint32 contregs_idx;
 
-      SCM_UNPACK_RTL_24 (op, nargs);
-      SCM_UNPACK_RTL_24 (ip[1], contregs_idx);
+      SCM_UNPACK_RTL_24 (op, contregs_idx);
 
       contregs = FREE_VARIABLE_REF (contregs_idx);
 
@@ -1252,34 +1248,33 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
       scm_i_check_continuation (contregs);
       vm_return_to_continuation (scm_i_contregs_vm (contregs),
                                  scm_i_contregs_vm_cont (contregs),
-                                 nargs, fp);
+                                 FRAME_LOCALS_COUNT (), fp);
       scm_i_reinstate_continuation (contregs);
 
       /* no NEXT */
       abort ();
     }
 
-  /* partial-cont nargs:24 _:8 cont:24
+  /* compose-continuation cont:24
    *
    * Compose a partial continution with the current continuation.  The
-   * NARGS values are taken from the stack, from slots 0 to NARGS-1.  CONT
-   * is a free variable containing the reified continuation.  This
+   * arguments to the continuation are taken from the stack.  CONT is a
+   * free variable containing the reified continuation.  This
    * instruction is part of the implementation of partial continuations,
    * and is not generated by the compiler.
    */
-  VM_DEFINE_OP (10, partial_cont_call, "partial-cont-call", OP2 (U8_U24, 
X8_U24))
+  VM_DEFINE_OP (10, compose_continuation, "compose-continuation", OP1 (U8_U24))
     {
       SCM vmcont;
       scm_t_uint32 cont_idx;
 
-      SCM_UNPACK_RTL_24 (op, nargs);
-      SCM_UNPACK_RTL_24 (ip[1], cont_idx);
+      SCM_UNPACK_RTL_24 (op, cont_idx);
       vmcont = LOCAL_REF (cont_idx);
 
       SYNC_IP ();
       VM_ASSERT (SCM_VM_CONT_REWINDABLE_P (vmcont),
                  vm_error_continuation_not_rewindable (vmcont));
-      vm_reinstate_partial_continuation (vm, vmcont, nargs, fp,
+      vm_reinstate_partial_continuation (vm, vmcont, FRAME_LOCALS_COUNT (), fp,
                                          &current_thread->dynstack,
                                          &registers);
       CACHE_REGISTER ();
@@ -1294,12 +1289,13 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    */
   VM_DEFINE_OP (11, apply, "apply", OP1 (U8_X24))
     {
-      int i, list_idx, list_len;
+      int i, list_idx, list_len, nargs;
       SCM list;
 
       VM_HANDLE_INTERRUPTS;
 
-      VM_ASSERT (nargs >= 2, abort ());
+      VM_ASSERT (FRAME_LOCALS_COUNT () >= 2, abort ());
+      nargs = FRAME_LOCALS_COUNT ();
       list_idx = nargs - 1;
       list = LOCAL_REF (list_idx);
       list_len = scm_ilength (list);
@@ -1356,8 +1352,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
 
       fp[-1] = fp[0];
       fp[0] = cont;
-      nargs = 1;
-      RESET_FRAME (nargs);
+      RESET_FRAME (1);
 
       APPLY_HOOK ();
 
@@ -1380,6 +1375,9 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
   VM_DEFINE_OP (13, values, "values", OP1 (U8_X24))
     {
       SCM *base = fp;
+#if VM_USE_HOOKS
+      int nargs = FRAME_LOCALS_COUNT ();
+#endif
 
       /* We don't do much; it's the caller that's responsible for
          shuffling values and resetting the stack.  */
@@ -1429,22 +1427,36 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
 
   /* assert-nargs-ee expected:24
    * assert-nargs-ge expected:24
+   * assert-nargs-le expected:24
    *
-   * If the number of actual arguments is not == or >= to EXPECTED,
+   * If the number of actual arguments is not ==, >=, or <= EXPECTED,
    * respectively, signal an error.
    */
   VM_DEFINE_OP (17, assert_nargs_ee, "assert-nargs-ee", OP1 (U8_U24))
     {
       scm_t_uint32 expected;
       SCM_UNPACK_RTL_24 (op, expected);
-      VM_ASSERT (nargs == expected, vm_error_wrong_num_args (vm, 
SCM_FRAME_PROGRAM (fp), nargs));
+      VM_ASSERT (FRAME_LOCALS_COUNT () == expected,
+                 vm_error_wrong_num_args (vm, SCM_FRAME_PROGRAM (fp),
+                                          FRAME_LOCALS_COUNT ()));
       NEXT (1);
     }
   VM_DEFINE_OP (18, assert_nargs_ge, "assert-nargs-ge", OP1 (U8_U24))
     {
       scm_t_uint32 expected;
       SCM_UNPACK_RTL_24 (op, expected);
-      VM_ASSERT (nargs >= expected, vm_error_wrong_num_args (vm, 
SCM_FRAME_PROGRAM (fp), nargs));
+      VM_ASSERT (FRAME_LOCALS_COUNT () >= expected,
+                 vm_error_wrong_num_args (vm, SCM_FRAME_PROGRAM (fp),
+                                          FRAME_LOCALS_COUNT ()));
+      NEXT (1);
+    }
+  VM_DEFINE_OP (19, assert_nargs_le, "assert-nargs-le", OP1 (U8_U24))
+    {
+      scm_t_uint32 expected;
+      SCM_UNPACK_RTL_24 (op, expected);
+      VM_ASSERT (FRAME_LOCALS_COUNT () <= expected,
+                 vm_error_wrong_num_args (vm, SCM_FRAME_PROGRAM (fp),
+                                          FRAME_LOCALS_COUNT ()));
       NEXT (1);
     }
 
@@ -1454,11 +1466,12 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * setting them all to SCM_UNDEFINED, except those nargs values that
    * were passed as arguments.
    */
-  VM_DEFINE_OP (19, reserve_locals, "reserve-locals", OP1 (U8_U24))
+  VM_DEFINE_OP (20, reserve_locals, "reserve-locals", OP1 (U8_U24))
     {
-      scm_t_uint32 nlocals;
+      scm_t_uint32 nlocals, nargs;
       SCM_UNPACK_RTL_24 (op, nlocals);
 
+      nargs = FRAME_LOCALS_COUNT ();
       ALLOC_FRAME (nlocals);
       while (nlocals-- > nargs)
         LOCAL_SET (nlocals, SCM_UNDEFINED);
@@ -1471,12 +1484,14 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * Equivalent to a sequence of assert-nargs-ee and reserve-locals.  The
    * number of locals reserved is EXPECTED + NLOCALS.
    */
-  VM_DEFINE_OP (20, assert_nargs_ee_locals, "assert-nargs-ee/locals", OP1 
(U8_U12_U12))
+  VM_DEFINE_OP (21, assert_nargs_ee_locals, "assert-nargs-ee/locals", OP1 
(U8_U12_U12))
     {
       scm_t_uint16 expected, nlocals;
       SCM_UNPACK_RTL_12_12 (op, expected, nlocals);
 
-      VM_ASSERT (nargs == expected, vm_error_wrong_num_args (vm, 
SCM_FRAME_PROGRAM (fp), nargs));
+      VM_ASSERT (FRAME_LOCALS_COUNT () == expected,
+                 vm_error_wrong_num_args (vm, SCM_FRAME_PROGRAM (fp),
+                                          FRAME_LOCALS_COUNT ()));
       ALLOC_FRAME (expected + nlocals);
       while (nlocals--)
         LOCAL_SET (expected + nlocals, SCM_UNDEFINED);
@@ -1496,9 +1511,9 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * A macro-mega-instruction.
    */
-  VM_DEFINE_OP (21, bind_kwargs, "bind-kwargs", OP4 (U8_U24, U8_U24, X8_U24, 
N32))
+  VM_DEFINE_OP (22, bind_kwargs, "bind-kwargs", OP4 (U8_U24, U8_U24, X8_U24, 
N32))
     {
-      scm_t_uint32 nreq, nreq_and_opt, ntotal, npositional, nkw, n;
+      scm_t_uint32 nreq, nreq_and_opt, ntotal, npositional, nkw, n, nargs;
       scm_t_int32 kw_offset;
       scm_t_bits kw_bits;
       SCM kw;
@@ -1514,6 +1529,8 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
       VM_ASSERT (!(kw_bits & 0x7), abort());
       kw = SCM_PACK (kw_bits);
 
+      nargs = FRAME_LOCALS_COUNT ();
+
       /* look in optionals for first keyword or last positional */
       /* starting after the last required positional arg */
       npositional = nreq;
@@ -1578,12 +1595,13 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * Collect any arguments at or above DST into a list, and store that
    * list at DST.
    */
-  VM_DEFINE_OP (22, bind_rest, "bind-rest", OP1 (U8_U24) | OP_DST)
+  VM_DEFINE_OP (23, bind_rest, "bind-rest", OP1 (U8_U24) | OP_DST)
     {
-      scm_t_uint32 dst;
+      scm_t_uint32 dst, nargs;
       SCM rest = SCM_EOL;
 
       SCM_UNPACK_RTL_24 (op, dst);
+      nargs = FRAME_LOCALS_COUNT ();
 
       while (nargs-- > dst)
         {
@@ -1603,13 +1621,13 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * Reset the stack pointer to only have space for NLOCALS values.
    * Used after extracting values from an MV return.
    */
-  VM_DEFINE_OP (23, drop_values, "drop-values", OP1 (U8_U24))
+  VM_DEFINE_OP (24, drop_values, "drop-values", OP1 (U8_U24))
     {
       scm_t_bits nlocals;
 
       SCM_UNPACK_RTL_24 (op, nlocals);
 
-      RESET_FRAME(nlocals);
+      RESET_FRAME (nlocals);
 
       NEXT (1);
     }
@@ -1626,7 +1644,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * Add OFFSET, a signed 24-bit number, to the current instruction
    * pointer.
    */
-  VM_DEFINE_OP (24, br, "br", OP1 (U8_L24))
+  VM_DEFINE_OP (25, br, "br", OP1 (U8_L24))
     {
       scm_t_int32 offset = op;
       offset >>= 8; /* Sign-extending shift. */
@@ -1638,7 +1656,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * If the value in TEST is true for the purposes of Scheme, add
    * OFFSET, a signed 24-bit number, to the current instruction pointer.
    */
-  VM_DEFINE_OP (25, br_if_true, "br-if-true", OP2 (U8_U24, U1_X7_L24))
+  VM_DEFINE_OP (26, br_if_true, "br-if-true", OP2 (U8_U24, B1_X7_L24))
     {
       BR_UNARY (x, scm_is_true (x));
     }
@@ -1648,7 +1666,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * If the value in TEST is the end-of-list or Lisp nil, add OFFSET, a
    * signed 24-bit number, to the current instruction pointer.
    */
-  VM_DEFINE_OP (26, br_if_null, "br-if-null", OP2 (U8_U24, U1_X7_L24))
+  VM_DEFINE_OP (27, br_if_null, "br-if-null", OP2 (U8_U24, B1_X7_L24))
     {
       BR_UNARY (x, scm_is_null (x));
     }
@@ -1658,7 +1676,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * If the value in TEST is false to Lisp, add OFFSET, a signed 24-bit
    * number, to the current instruction pointer.
    */
-  VM_DEFINE_OP (27, br_if_nil, "br-if-nil", OP2 (U8_U24, U1_X7_L24))
+  VM_DEFINE_OP (28, br_if_nil, "br-if-nil", OP2 (U8_U24, B1_X7_L24))
     {
       BR_UNARY (x, scm_is_lisp_false (x));
     }
@@ -1668,7 +1686,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * If the value in TEST is a pair, add OFFSET, a signed 24-bit number,
    * to the current instruction pointer.
    */
-  VM_DEFINE_OP (28, br_if_pair, "br-if-pair", OP2 (U8_U24, U1_X7_L24))
+  VM_DEFINE_OP (29, br_if_pair, "br-if-pair", OP2 (U8_U24, B1_X7_L24))
     {
       BR_UNARY (x, scm_is_pair (x));
     }
@@ -1678,7 +1696,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * If the value in TEST is a struct, add OFFSET, a signed 24-bit
    * number, to the current instruction pointer.
    */
-  VM_DEFINE_OP (29, br_if_struct, "br-if-struct", OP2 (U8_U24, U1_X7_L24))
+  VM_DEFINE_OP (30, br_if_struct, "br-if-struct", OP2 (U8_U24, B1_X7_L24))
     {
       BR_UNARY (x, SCM_STRUCTP (x));
     }
@@ -1688,7 +1706,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * If the value in TEST is a char, add OFFSET, a signed 24-bit number,
    * to the current instruction pointer.
    */
-  VM_DEFINE_OP (30, br_if_char, "br-if-char", OP2 (U8_U24, U1_X7_L24))
+  VM_DEFINE_OP (31, br_if_char, "br-if-char", OP2 (U8_U24, B1_X7_L24))
     {
       BR_UNARY (x, SCM_CHARP (x));
     }
@@ -1698,7 +1716,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * If the value in TEST has the TC7 given in the second word, add
    * OFFSET, a signed 24-bit number, to the current instruction pointer.
    */
-  VM_DEFINE_OP (31, br_if_tc7, "br-if-tc7", OP2 (U8_U24, U1_U7_L24))
+  VM_DEFINE_OP (32, br_if_tc7, "br-if-tc7", OP2 (U8_U24, B1_U7_L24))
     {
       BR_UNARY (x, SCM_HAS_TYP7 (x, (ip[1] >> 1) & 0x7f));
     }
@@ -1708,7 +1726,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * If the value in A is eq? to the value in B, add OFFSET, a signed
    * 24-bit number, to the current instruction pointer.
    */
-  VM_DEFINE_OP (32, br_if_eq, "br-if-eq", OP2 (U8_U12_U12, U1_X7_L24))
+  VM_DEFINE_OP (33, br_if_eq, "br-if-eq", OP2 (U8_U12_U12, B1_X7_L24))
     {
       BR_BINARY (x, y, scm_is_eq (x, y));
     }
@@ -1718,7 +1736,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * If the value in A is eqv? to the value in B, add OFFSET, a signed
    * 24-bit number, to the current instruction pointer.
    */
-  VM_DEFINE_OP (33, br_if_eqv, "br-if-eqv", OP2 (U8_U12_U12, U1_X7_L24))
+  VM_DEFINE_OP (34, br_if_eqv, "br-if-eqv", OP2 (U8_U12_U12, B1_X7_L24))
     {
       BR_BINARY (x, y,
                  scm_is_eq (x, y)
@@ -1732,7 +1750,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * 24-bit number, to the current instruction pointer.
    */
   // FIXME: should sync_ip before calling out?
-  VM_DEFINE_OP (34, br_if_equal, "br-if-equal", OP2 (U8_U12_U12, U1_X7_L24))
+  VM_DEFINE_OP (35, br_if_equal, "br-if-equal", OP2 (U8_U12_U12, B1_X7_L24))
     {
       BR_BINARY (x, y,
                  scm_is_eq (x, y)
@@ -1745,7 +1763,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * If the value in A is = to the value in B, add OFFSET, a signed
    * 24-bit number, to the current instruction pointer.
    */
-  VM_DEFINE_OP (35, br_if_ee, "br-if-=", OP2 (U8_U12_U12, X8_L24))
+  VM_DEFINE_OP (36, br_if_ee, "br-if-=", OP2 (U8_U12_U12, X8_L24))
     {
       BR_ARITHMETIC (==, scm_num_eq_p);
     }
@@ -1755,7 +1773,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * If the value in A is < to the value in B, add OFFSET, a signed
    * 24-bit number, to the current instruction pointer.
    */
-  VM_DEFINE_OP (36, br_if_lt, "br-if-<", OP2 (U8_U12_U12, X8_L24))
+  VM_DEFINE_OP (37, br_if_lt, "br-if-<", OP2 (U8_U12_U12, X8_L24))
     {
       BR_ARITHMETIC (<, scm_less_p);
     }
@@ -1765,7 +1783,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * If the value in A is <= to the value in B, add OFFSET, a signed
    * 24-bit number, to the current instruction pointer.
    */
-  VM_DEFINE_OP (37, br_if_le, "br-if-<=", OP2 (U8_U12_U12, X8_L24))
+  VM_DEFINE_OP (38, br_if_le, "br-if-<=", OP2 (U8_U12_U12, X8_L24))
     {
       BR_ARITHMETIC (<=, scm_leq_p);
     }
@@ -1775,7 +1793,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * If the value in A is > to the value in B, add OFFSET, a signed
    * 24-bit number, to the current instruction pointer.
    */
-  VM_DEFINE_OP (38, br_if_gt, "br-if->", OP2 (U8_U12_U12, X8_L24))
+  VM_DEFINE_OP (39, br_if_gt, "br-if->", OP2 (U8_U12_U12, X8_L24))
     {
       BR_ARITHMETIC (>, scm_gr_p);
     }
@@ -1785,7 +1803,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * If the value in A is >= to the value in B, add OFFSET, a signed
    * 24-bit number, to the current instruction pointer.
    */
-  VM_DEFINE_OP (39, br_if_ge, "br-if->=", OP2 (U8_U12_U12, X8_L24))
+  VM_DEFINE_OP (40, br_if_ge, "br-if->=", OP2 (U8_U12_U12, X8_L24))
     {
       BR_ARITHMETIC (>=, scm_geq_p);
     }
@@ -1801,7 +1819,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Copy a value from one local slot to another.
    */
-  VM_DEFINE_OP (40, mov, "mov", OP1 (U8_U12_U12) | OP_DST)
+  VM_DEFINE_OP (41, mov, "mov", OP1 (U8_U12_U12) | OP_DST)
     {
       scm_t_uint16 dst;
       scm_t_uint16 src;
@@ -1816,7 +1834,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Copy a value from one local slot to another.
    */
-  VM_DEFINE_OP (41, long_mov, "long-mov", OP2 (U8_U24, X8_U24) | OP_DST)
+  VM_DEFINE_OP (42, long_mov, "long-mov", OP2 (U8_U24, X8_U24) | OP_DST)
     {
       scm_t_uint32 dst;
       scm_t_uint32 src;
@@ -1832,7 +1850,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Create a new variable holding SRC, and place it in DST.
    */
-  VM_DEFINE_OP (42, box, "box", OP1 (U8_U12_U12) | OP_DST)
+  VM_DEFINE_OP (43, box, "box", OP1 (U8_U12_U12) | OP_DST)
     {
       scm_t_uint16 dst, src;
       SCM_UNPACK_RTL_12_12 (op, dst, src);
@@ -1846,7 +1864,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * general implementation of `letrec', in those cases that fix-letrec
    * fails to fix.
    */
-  VM_DEFINE_OP (43, empty_box, "empty-box", OP1 (U8_U24) | OP_DST)
+  VM_DEFINE_OP (44, empty_box, "empty-box", OP1 (U8_U24) | OP_DST)
     {
       scm_t_uint32 dst;
       SCM_UNPACK_RTL_24 (op, dst);
@@ -1859,7 +1877,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * Unpack the variable at SRC into DST, asserting that the variable is
    * actually bound.
    */
-  VM_DEFINE_OP (44, box_ref, "box-ref", OP1 (U8_U12_U12) | OP_DST)
+  VM_DEFINE_OP (45, box_ref, "box-ref", OP1 (U8_U12_U12) | OP_DST)
     {
       scm_t_uint16 dst, src;
       SCM var;
@@ -1882,7 +1900,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Set the contents of the variable at DST to SET.
    */
-  VM_DEFINE_OP (45, box_set, "box-set!", OP1 (U8_U12_U12) | OP_DST)
+  VM_DEFINE_OP (46, box_set, "box-set!", OP1 (U8_U12_U12) | OP_DST)
     {
       scm_t_uint16 dst, src;
       SCM var;
@@ -1897,7 +1915,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Load free variable SRC into local slot DST.
    */
-  VM_DEFINE_OP (46, free_ref, "free-ref", OP1 (U8_U12_U12) | OP_DST)
+  VM_DEFINE_OP (47, free_ref, "free-ref", OP1 (U8_U12_U12) | OP_DST)
     {
       scm_t_uint16 dst, src;
       SCM_UNPACK_RTL_12_12 (op, dst, src);
@@ -1913,7 +1931,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * signed 32-bit integer.  The registers for the NFREE free variables
    * follow.
    */
-  VM_DEFINE_OP (47, make_closure, "make-closure", OP3 (U8_U24, L32, X8_R24) | 
OP_DST)
+  VM_DEFINE_OP (48, make_closure, "make-closure", OP3 (U8_U24, L32, X8_R24) | 
OP_DST)
     {
       scm_t_uint32 dst, nfree, n;
       scm_t_int32 offset;
@@ -1940,7 +1958,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * free variables to point to each other.  NFREE and the locals FREE0...
    * are as in make-closure.
    */
-  VM_DEFINE_OP (48, fix_closure, "fix-closure", OP2 (U8_U24, X8_R24))
+  VM_DEFINE_OP (49, fix_closure, "fix-closure", OP2 (U8_U24, X8_R24))
     {
       scm_t_uint32 dst, nfree, n;
       SCM closure;
@@ -1965,7 +1983,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * Make an immediate whose low bits are LOW-BITS, and whose top bits are
    * 0.
    */
-  VM_DEFINE_OP (49, make_short_immediate, "make-short-immediate", OP1 
(U8_U8_I16) | OP_DST)
+  VM_DEFINE_OP (50, make_short_immediate, "make-short-immediate", OP1 
(U8_U8_I16) | OP_DST)
     {
       scm_t_uint8 dst;
       scm_t_bits val;
@@ -1980,7 +1998,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * Make an immediate whose low bits are LOW-BITS, and whose top bits are
    * 0.
    */
-  VM_DEFINE_OP (50, make_long_immediate, "make-long-immediate", OP2 (U8_U24, 
I32))
+  VM_DEFINE_OP (51, make_long_immediate, "make-long-immediate", OP2 (U8_U24, 
I32))
     {
       scm_t_uint8 dst;
       scm_t_bits val;
@@ -1995,7 +2013,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Make an immediate with HIGH-BITS and LOW-BITS.
    */
-  VM_DEFINE_OP (51, make_long_long_immediate, "make-long-long-immediate", OP3 
(U8_U24, A32, B32) | OP_DST)
+  VM_DEFINE_OP (52, make_long_long_immediate, "make-long-long-immediate", OP3 
(U8_U24, A32, B32) | OP_DST)
     {
       scm_t_uint8 dst;
       scm_t_bits val;
@@ -2026,7 +2044,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * Whether the object is mutable or immutable depends on where it was
    * allocated by the compiler, and loaded by the loader.
    */
-  VM_DEFINE_OP (52, make_non_immediate, "make-non-immediate", OP2 (U8_U24, 
N32) | OP_DST)
+  VM_DEFINE_OP (53, make_non_immediate, "make-non-immediate", OP2 (U8_U24, 
N32) | OP_DST)
     {
       scm_t_uint32 dst;
       scm_t_int32 offset;
@@ -2055,7 +2073,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * that the compiler is unable to statically allocate, like symbols.
    * These values would be initialized when the object file loads.
    */
-  VM_DEFINE_OP (53, static_ref, "static-ref", OP2 (U8_U24, S32))
+  VM_DEFINE_OP (54, static_ref, "static-ref", OP2 (U8_U24, S32))
     {
       scm_t_uint32 dst;
       scm_t_int32 offset;
@@ -2078,7 +2096,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * Store a SCM value into memory, OFFSET 32-bit words away from the
    * current instruction pointer.  OFFSET is a signed value.
    */
-  VM_DEFINE_OP (54, static_set, "static-set!", OP2 (U8_U24, LO32))
+  VM_DEFINE_OP (55, static_set, "static-set!", OP2 (U8_U24, LO32))
     {
       scm_t_uint32 src;
       scm_t_int32 offset;
@@ -2100,7 +2118,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * words away from the current instruction pointer.  OFFSET is a
    * signed value.
    */
-  VM_DEFINE_OP (55, link_procedure, "link-procedure!", OP2 (U8_U24, L32))
+  VM_DEFINE_OP (56, link_procedure, "link-procedure!", OP2 (U8_U24, L32))
     {
       scm_t_uint32 src;
       scm_t_int32 offset;
@@ -2161,7 +2179,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Store the current module in DST.
    */
-  VM_DEFINE_OP (56, current_module, "current-module", OP1 (U8_U24) | OP_DST)
+  VM_DEFINE_OP (57, current_module, "current-module", OP1 (U8_U24) | OP_DST)
     {
       scm_t_uint32 dst;
 
@@ -2177,7 +2195,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Resolve SYM in MOD, and place the resulting variable in DST.
    */
-  VM_DEFINE_OP (57, resolve, "resolve", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (58, resolve, "resolve", OP1 (U8_U8_U8_U8) | OP_DST)
     {
       scm_t_uint8 dst, mod, sym;
 
@@ -2195,7 +2213,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * nonzero, resolve the public interface, otherwise use the private
    * interface.
    */
-  VM_DEFINE_OP (58, resolve_module, "resolve-module", OP1 (U8_U8_U8_U8) | 
OP_DST)
+  VM_DEFINE_OP (59, resolve_module, "resolve-module", OP1 (U8_U8_U8_U8) | 
OP_DST)
     {
       scm_t_uint8 dst, name, public;
       SCM mod;
@@ -2216,7 +2234,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * Look up a binding for SYM in the current module, creating it if
    * necessary.  Set its value to VAL.
    */
-  VM_DEFINE_OP (59, define, "define", OP1 (U8_U12_U12))
+  VM_DEFINE_OP (60, define, "define", OP1 (U8_U12_U12))
     {
       scm_t_uint16 sym, val;
       SCM_UNPACK_RTL_12_12 (op, sym, val);
@@ -2244,7 +2262,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * an error if it is unbound, unbox it into DST, and cache the
    * resolved variable so that we will hit the cache next time.
    */
-  VM_DEFINE_OP (60, toplevel_ref, "toplevel-ref", OP4 (U8_U24, S32, S32, N32) 
| OP_DST)
+  VM_DEFINE_OP (61, toplevel_ref, "toplevel-ref", OP4 (U8_U24, S32, S32, N32) 
| OP_DST)
     {
       scm_t_uint32 dst;
       scm_t_int32 var_offset;
@@ -2290,7 +2308,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * Set a top-level variable from a variable cache cell.  The variable
    * is resolved as in toplevel-ref.
    */
-  VM_DEFINE_OP (61, toplevel_set, "toplevel-set!", OP4 (U8_U24, S32, S32, N32))
+  VM_DEFINE_OP (62, toplevel_set, "toplevel-set!", OP4 (U8_U24, S32, S32, N32))
     {
       scm_t_uint32 src;
       scm_t_int32 var_offset;
@@ -2335,7 +2353,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * Like toplevel-ref, except MOD-OFFSET points at the name of a module
    * instead of the module itself.
    */
-  VM_DEFINE_OP (62, module_ref, "module-ref", OP4 (U8_U24, S32, N32, N32) | 
OP_DST)
+  VM_DEFINE_OP (63, module_ref, "module-ref", OP4 (U8_U24, S32, N32, N32) | 
OP_DST)
     {
       scm_t_uint32 dst;
       scm_t_int32 var_offset;
@@ -2385,7 +2403,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * Like toplevel-set!, except MOD-OFFSET points at the name of a module
    * instead of the module itself.
    */
-  VM_DEFINE_OP (63, module_set, "module-set!", OP4 (U8_U24, S32, N32, N32))
+  VM_DEFINE_OP (64, module_set, "module-set!", OP4 (U8_U24, S32, N32, N32))
     {
       scm_t_uint32 src;
       scm_t_int32 var_offset;
@@ -2440,7 +2458,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * handler at HANDLER-OFFSET words from the current IP.  The handler
    * will expect a multiple-value return.
    */
-  VM_DEFINE_OP (64, prompt, "prompt", OP2 (U8_U24, U8_L24))
+  VM_DEFINE_OP (65, prompt, "prompt", OP2 (U8_U24, U8_L24))
 #if 0
     {
       scm_t_uint32 tag;
@@ -2472,7 +2490,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * the compiler should have inserted checks that they wind and unwind
    * procs are thunks, if it could not prove that to be the case.
    */
-  VM_DEFINE_OP (65, wind, "wind", OP1 (U8_U12_U12))
+  VM_DEFINE_OP (66, wind, "wind", OP1 (U8_U12_U12))
     {
       scm_t_uint16 winder, unwinder;
       SCM_UNPACK_RTL_12_12 (op, winder, unwinder);
@@ -2487,7 +2505,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * VAL1, etc are 24-bit values, in the lower 24 bits of their words.
    * The upper 8 bits are 0.
    */
-  VM_DEFINE_OP (66, abort, "abort", OP2 (U8_U24, X8_R24))
+  VM_DEFINE_OP (67, abort, "abort", OP2 (U8_U24, X8_R24))
 #if 0
     {
       scm_t_uint32 tag, nvalues;
@@ -2510,7 +2528,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * A normal exit from the dynamic extent of an expression. Pop the top
    * entry off of the dynamic stack.
    */
-  VM_DEFINE_OP (67, unwind, "unwind", OP1 (U8_X24))
+  VM_DEFINE_OP (68, unwind, "unwind", OP1 (U8_X24))
     {
       scm_dynstack_pop (&current_thread->dynstack);
       NEXT (1);
@@ -2522,7 +2540,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * allocated in a continguous range on the stack, starting from
    * FLUID-BASE.  The values do not have this restriction.
    */
-  VM_DEFINE_OP (68, wind_fluids, "wind-fluids", OP2 (U8_U24, X8_R24))
+  VM_DEFINE_OP (69, wind_fluids, "wind-fluids", OP2 (U8_U24, X8_R24))
 #if 0
     {
       scm_t_uint32 fluid_base, n;
@@ -2544,7 +2562,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * Leave the dynamic extent of a with-fluids expression, restoring the
    * fluids to their previous values.
    */
-  VM_DEFINE_OP (69, unwind_fluids, "unwind-fluids", OP1 (U8_X24))
+  VM_DEFINE_OP (70, unwind_fluids, "unwind-fluids", OP1 (U8_X24))
     {
       /* This function must not allocate.  */
       scm_dynstack_unwind_fluids (&current_thread->dynstack,
@@ -2556,7 +2574,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Reference the fluid in SRC, and place the value in DST.
    */
-  VM_DEFINE_OP (70, fluid_ref, "fluid-ref", OP1 (U8_U12_U12) | OP_DST)
+  VM_DEFINE_OP (71, fluid_ref, "fluid-ref", OP1 (U8_U12_U12) | OP_DST)
     {
       scm_t_uint16 dst, src;
       size_t num;
@@ -2589,7 +2607,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Set the value of the fluid in DST to the value in SRC.
    */
-  VM_DEFINE_OP (71, fluid_set, "fluid-set", OP1 (U8_U12_U12))
+  VM_DEFINE_OP (72, fluid_set, "fluid-set", OP1 (U8_U12_U12))
     {
       scm_t_uint16 a, b;
       size_t num;
@@ -2622,7 +2640,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Store the length of the string in SRC in DST.
    */
-  VM_DEFINE_OP (72, string_length, "string-length", OP1 (U8_U12_U12) | OP_DST)
+  VM_DEFINE_OP (73, string_length, "string-length", OP1 (U8_U12_U12) | OP_DST)
     {
       ARGS1 (str);
       if (SCM_LIKELY (scm_is_string (str)))
@@ -2639,7 +2657,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * Fetch the character at position IDX in the string in SRC, and store
    * it in DST.
    */
-  VM_DEFINE_OP (73, string_ref, "string-ref", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (74, string_ref, "string-ref", OP1 (U8_U8_U8_U8) | OP_DST)
     {
       scm_t_signed_bits i = 0;
       ARGS2 (str, idx);
@@ -2661,7 +2679,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Parse a string in SRC to a number, and store in DST.
    */
-  VM_DEFINE_OP (74, string_to_number, "string->number", OP1 (U8_U12_U12) | 
OP_DST)
+  VM_DEFINE_OP (75, string_to_number, "string->number", OP1 (U8_U12_U12) | 
OP_DST)
     {
       scm_t_uint16 dst, src;
 
@@ -2677,7 +2695,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Parse a string in SRC to a symbol, and store in DST.
    */
-  VM_DEFINE_OP (75, string_to_symbol, "string->symbol", OP1 (U8_U12_U12) | 
OP_DST)
+  VM_DEFINE_OP (76, string_to_symbol, "string->symbol", OP1 (U8_U12_U12) | 
OP_DST)
     {
       scm_t_uint16 dst, src;
 
@@ -2691,7 +2709,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Make a keyword from the symbol in SRC, and store it in DST.
    */
-  VM_DEFINE_OP (76, symbol_to_keyword, "symbol->keyword", OP1 (U8_U12_U12) | 
OP_DST)
+  VM_DEFINE_OP (77, symbol_to_keyword, "symbol->keyword", OP1 (U8_U12_U12) | 
OP_DST)
     {
       scm_t_uint16 dst, src;
       SCM_UNPACK_RTL_12_12 (op, dst, src);
@@ -2710,7 +2728,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Cons CAR and CDR, and store the result in DST.
    */
-  VM_DEFINE_OP (77, cons, "cons", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (78, cons, "cons", OP1 (U8_U8_U8_U8) | OP_DST)
     {
       ARGS2 (x, y);
       RETURN (scm_cons (x, y));
@@ -2720,7 +2738,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Place the car of SRC in DST.
    */
-  VM_DEFINE_OP (78, car, "car", OP1 (U8_U12_U12) | OP_DST)
+  VM_DEFINE_OP (79, car, "car", OP1 (U8_U12_U12) | OP_DST)
     {
       ARGS1 (x);
       VM_VALIDATE_PAIR (x, "car");
@@ -2731,7 +2749,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Place the cdr of SRC in DST.
    */
-  VM_DEFINE_OP (79, cdr, "cdr", OP1 (U8_U12_U12) | OP_DST)
+  VM_DEFINE_OP (80, cdr, "cdr", OP1 (U8_U12_U12) | OP_DST)
     {
       ARGS1 (x);
       VM_VALIDATE_PAIR (x, "cdr");
@@ -2742,7 +2760,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Set the car of DST to SRC.
    */
-  VM_DEFINE_OP (80, set_car, "set-car!", OP1 (U8_U12_U12))
+  VM_DEFINE_OP (81, set_car, "set-car!", OP1 (U8_U12_U12))
     {
       scm_t_uint16 a, b;
       SCM x, y;
@@ -2758,7 +2776,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Set the cdr of DST to SRC.
    */
-  VM_DEFINE_OP (81, set_cdr, "set-cdr!", OP1 (U8_U12_U12))
+  VM_DEFINE_OP (82, set_cdr, "set-cdr!", OP1 (U8_U12_U12))
     {
       scm_t_uint16 a, b;
       SCM x, y;
@@ -2781,7 +2799,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Add A to B, and place the result in DST.
    */
-  VM_DEFINE_OP (82, add, "add", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (83, add, "add", OP1 (U8_U8_U8_U8) | OP_DST)
     {
       BINARY_INTEGER_OP (+, scm_sum);
     }
@@ -2790,7 +2808,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Add 1 to the value in SRC, and place the result in DST.
    */
-  VM_DEFINE_OP (83, add1, "add1", OP1 (U8_U12_U12) | OP_DST)
+  VM_DEFINE_OP (84, add1, "add1", OP1 (U8_U12_U12) | OP_DST)
     {
       ARGS1 (x);
 
@@ -2816,7 +2834,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Subtract B from A, and place the result in DST.
    */
-  VM_DEFINE_OP (84, sub, "sub", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (85, sub, "sub", OP1 (U8_U8_U8_U8) | OP_DST)
     {
       BINARY_INTEGER_OP (-, scm_difference);
     }
@@ -2825,7 +2843,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Subtract 1 from SRC, and place the result in DST.
    */
-  VM_DEFINE_OP (85, sub1, "sub1", OP1 (U8_U12_U12) | OP_DST)
+  VM_DEFINE_OP (86, sub1, "sub1", OP1 (U8_U12_U12) | OP_DST)
     {
       ARGS1 (x);
 
@@ -2851,7 +2869,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Multiply A and B, and place the result in DST.
    */
-  VM_DEFINE_OP (86, mul, "mul", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (87, mul, "mul", OP1 (U8_U8_U8_U8) | OP_DST)
     {
       ARGS2 (x, y);
       SYNC_IP ();
@@ -2862,7 +2880,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Divide A by B, and place the result in DST.
    */
-  VM_DEFINE_OP (87, div, "div", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (88, div, "div", OP1 (U8_U8_U8_U8) | OP_DST)
     {
       ARGS2 (x, y);
       SYNC_IP ();
@@ -2873,7 +2891,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Divide A by B, and place the quotient in DST.
    */
-  VM_DEFINE_OP (88, quo, "quo", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (89, quo, "quo", OP1 (U8_U8_U8_U8) | OP_DST)
     {
       ARGS2 (x, y);
       SYNC_IP ();
@@ -2884,7 +2902,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Divide A by B, and place the remainder in DST.
    */
-  VM_DEFINE_OP (89, rem, "rem", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (90, rem, "rem", OP1 (U8_U8_U8_U8) | OP_DST)
     {
       ARGS2 (x, y);
       SYNC_IP ();
@@ -2895,7 +2913,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Place the modulo of A by B in DST.
    */
-  VM_DEFINE_OP (90, mod, "mod", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (91, mod, "mod", OP1 (U8_U8_U8_U8) | OP_DST)
     {
       ARGS2 (x, y);
       SYNC_IP ();
@@ -2906,7 +2924,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Shift A arithmetically by B bits, and place the result in DST.
    */
-  VM_DEFINE_OP (91, ash, "ash", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (92, ash, "ash", OP1 (U8_U8_U8_U8) | OP_DST)
     {
       ARGS2 (x, y);
       if (SCM_I_INUMP (x) && SCM_I_INUMP (y))
@@ -2939,7 +2957,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Place the bitwise AND of A and B into DST.
    */
-  VM_DEFINE_OP (92, logand, "logand", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (93, logand, "logand", OP1 (U8_U8_U8_U8) | OP_DST)
     {
       ARGS2 (x, y);
       if (SCM_I_INUMP (x) && SCM_I_INUMP (y))
@@ -2952,7 +2970,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Place the bitwise inclusive OR of A with B in DST.
    */
-  VM_DEFINE_OP (93, logior, "logior", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (94, logior, "logior", OP1 (U8_U8_U8_U8) | OP_DST)
     {
       ARGS2 (x, y);
       if (SCM_I_INUMP (x) && SCM_I_INUMP (y))
@@ -2965,7 +2983,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Place the bitwise exclusive OR of A with B in DST.
    */
-  VM_DEFINE_OP (94, logxor, "logxor", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (95, logxor, "logxor", OP1 (U8_U8_U8_U8) | OP_DST)
     {
       ARGS2 (x, y);
       if (SCM_I_INUMP (x) && SCM_I_INUMP (y))
@@ -2978,7 +2996,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Store the length of the vector in SRC in DST.
    */
-  VM_DEFINE_OP (95, vector_length, "vector-length", OP1 (U8_U12_U12) | OP_DST)
+  VM_DEFINE_OP (96, vector_length, "vector-length", OP1 (U8_U12_U12) | OP_DST)
     {
       ARGS1 (vect);
       if (SCM_LIKELY (SCM_I_IS_VECTOR (vect)))
@@ -2995,7 +3013,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * Fetch the item at position IDX in the vector in SRC, and store it
    * in DST.
    */
-  VM_DEFINE_OP (96, vector_ref, "vector-ref", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (97, vector_ref, "vector-ref", OP1 (U8_U8_U8_U8) | OP_DST)
     {
       scm_t_signed_bits i = 0;
       ARGS2 (vect, idx);
@@ -3016,7 +3034,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * Fill DST with the item IDX elements into the vector at SRC.  Useful
    * for building data types using vectors.
    */
-  VM_DEFINE_OP (97, constant_vector_ref, "constant-vector-ref", OP1 
(U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (98, constant_vector_ref, "constant-vector-ref", OP1 
(U8_U8_U8_U8) | OP_DST)
     {
       scm_t_uint8 dst, src, idx;
       SCM v;
@@ -3035,7 +3053,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Store SRC into the vector DST at index IDX.
    */
-  VM_DEFINE_OP (98, vector_set, "vector-set", OP1 (U8_U8_U8_U8))
+  VM_DEFINE_OP (99, vector_set, "vector-set", OP1 (U8_U8_U8_U8))
     {
       scm_t_uint8 dst, idx_var, src;
       SCM vect, idx, val;
@@ -3070,7 +3088,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Store the vtable of SRC into DST.
    */
-  VM_DEFINE_OP (99, struct_vtable, "struct-vtable", OP1 (U8_U12_U12) | OP_DST)
+  VM_DEFINE_OP (100, struct_vtable, "struct-vtable", OP1 (U8_U12_U12) | OP_DST)
     {
       ARGS1 (obj);
       VM_VALIDATE_STRUCT (obj, "struct_vtable");
@@ -3084,7 +3102,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * the locals given by INIT0....  The format of INIT0... is as in the
    * "call" opcode: unsigned 24-bit values, with 0 in the high byte.
    */
-  VM_DEFINE_OP (100, make_struct, "make-struct", OP2 (U8_U12_U12, X8_R24))
+  VM_DEFINE_OP (101, make_struct, "make-struct", OP2 (U8_U12_U12, X8_R24))
 #if 0
     {
       scm_t_uint16 dst, vtable_r;
@@ -3127,7 +3145,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * Fetch the item at slot IDX in the struct in SRC, and store it
    * in DST.
    */
-  VM_DEFINE_OP (101, struct_ref, "struct-ref", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (102, struct_ref, "struct-ref", OP1 (U8_U8_U8_U8) | OP_DST)
     {
       ARGS2 (obj, pos);
 
@@ -3161,7 +3179,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Store SRC into the struct DST at slot IDX.
    */
-  VM_DEFINE_OP (102, struct_set, "struct-set!", OP1 (U8_U8_U8_U8))
+  VM_DEFINE_OP (103, struct_set, "struct-set!", OP1 (U8_U8_U8_U8))
     {
       scm_t_uint8 dst, idx, src;
       SCM obj, pos, val;
@@ -3202,7 +3220,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    *
    * Store the vtable of SRC into DST.
    */
-  VM_DEFINE_OP (103, class_of, "class-of", OP1 (U8_U12_U12) | OP_DST)
+  VM_DEFINE_OP (104, class_of, "class-of", OP1 (U8_U12_U12) | OP_DST)
     {
       ARGS1 (obj);
       if (SCM_INSTANCEP (obj))
@@ -3217,7 +3235,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * DST.  Unlike struct-ref, IDX is an 8-bit immediate value, not an
    * index into the stack.
    */
-  VM_DEFINE_OP (104, slot_ref, "slot-ref", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (105, slot_ref, "slot-ref", OP1 (U8_U8_U8_U8) | OP_DST)
     {
       scm_t_uint8 dst, src, idx;
       SCM_UNPACK_RTL_8_8_8 (op, dst, src, idx);
@@ -3231,7 +3249,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * Store SRC into slot IDX of the struct in DST.  Unlike struct-set!,
    * IDX is an 8-bit immediate value, not an index into the stack.
    */
-  VM_DEFINE_OP (105, slot_set, "slot-set!", OP1 (U8_U8_U8_U8))
+  VM_DEFINE_OP (106, slot_set, "slot-set!", OP1 (U8_U8_U8_U8))
     {
       scm_t_uint8 dst, idx, src;
       SCM_UNPACK_RTL_8_8_8 (op, dst, idx, src);
@@ -3252,7 +3270,7 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
    * from the instruction pointer, and store into DST.  LEN is a byte
    * length.  OFFSET is signed.
    */
-  VM_DEFINE_OP (106, load_typed_array, "load-typed-array", OP3 (U8_U8_U8_U8, 
N32, U32) | OP_DST)
+  VM_DEFINE_OP (107, load_typed_array, "load-typed-array", OP3 (U8_U8_U8_U8, 
N32, U32) | OP_DST)
     {
       scm_t_uint8 dst, type, shape;
       scm_t_int32 offset;
@@ -3270,9 +3288,9 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
 
   /* make-array dst:12 type:12 _:8 fill:12 bounds:12
    *
-   * Make a new array SRC into the vector DST at index IDX.
+   * Make a new array with TYPE, FILL, and BOUNDS, storing it in DST.
    */
-  VM_DEFINE_OP (107, make_array, "make-array", OP2 (U8_U12_U12, X8_U12_U12) | 
OP_DST)
+  VM_DEFINE_OP (108, make_array, "make-array", OP2 (U8_U12_U12, X8_U12_U12) | 
OP_DST)
     {
       scm_t_uint16 dst, type, fill, bounds;
       SCM_UNPACK_RTL_12_12 (op, dst, type);
@@ -3370,42 +3388,42 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
       RETURN (scm_bytevector_ ## fn_stem ## _native_ref (bv, idx));    \
   } while (0)
 
-  VM_DEFINE_OP (108, bv_u8_ref, "bv-u8-ref", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (109, bv_u8_ref, "bv-u8-ref", OP1 (U8_U8_U8_U8) | OP_DST)
     BV_FIXABLE_INT_REF (u8, u8, uint8, 1);
 
-  VM_DEFINE_OP (109, bv_s8_ref, "bv-s8-ref", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (110, bv_s8_ref, "bv-s8-ref", OP1 (U8_U8_U8_U8) | OP_DST)
     BV_FIXABLE_INT_REF (s8, s8, int8, 1);
 
-  VM_DEFINE_OP (110, bv_u16_ref, "bv-u16-ref", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (111, bv_u16_ref, "bv-u16-ref", OP1 (U8_U8_U8_U8) | OP_DST)
     BV_FIXABLE_INT_REF (u16, u16_native, uint16, 2);
 
-  VM_DEFINE_OP (111, bv_s16_ref, "bv-s16-ref", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (112, bv_s16_ref, "bv-s16-ref", OP1 (U8_U8_U8_U8) | OP_DST)
     BV_FIXABLE_INT_REF (s16, s16_native, int16, 2);
 
-  VM_DEFINE_OP (112, bv_u32_ref, "bv-u32-ref", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (113, bv_u32_ref, "bv-u32-ref", OP1 (U8_U8_U8_U8) | OP_DST)
 #if SIZEOF_VOID_P > 4
     BV_FIXABLE_INT_REF (u32, u32_native, uint32, 4);
 #else
     BV_INT_REF (u32, uint32, 4);
 #endif
 
-  VM_DEFINE_OP (113, bv_s32_ref, "bv-s32-ref", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (114, bv_s32_ref, "bv-s32-ref", OP1 (U8_U8_U8_U8) | OP_DST)
 #if SIZEOF_VOID_P > 4
     BV_FIXABLE_INT_REF (s32, s32_native, int32, 4);
 #else
     BV_INT_REF (s32, int32, 4);
 #endif
 
-  VM_DEFINE_OP (114, bv_u64_ref, "bv-u64-ref", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (115, bv_u64_ref, "bv-u64-ref", OP1 (U8_U8_U8_U8) | OP_DST)
     BV_INT_REF (u64, uint64, 8);
 
-  VM_DEFINE_OP (115, bv_s64_ref, "bv-s64-ref", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (116, bv_s64_ref, "bv-s64-ref", OP1 (U8_U8_U8_U8) | OP_DST)
     BV_INT_REF (s64, int64, 8);
 
-  VM_DEFINE_OP (116, bv_f32_ref, "bv-f32-ref", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (117, bv_f32_ref, "bv-f32-ref", OP1 (U8_U8_U8_U8) | OP_DST)
     BV_FLOAT_REF (f32, ieee_single, float, 4);
 
-  VM_DEFINE_OP (117, bv_f64_ref, "bv-f64-ref", OP1 (U8_U8_U8_U8) | OP_DST)
+  VM_DEFINE_OP (118, bv_f64_ref, "bv-f64-ref", OP1 (U8_U8_U8_U8) | OP_DST)
     BV_FLOAT_REF (f64, ieee_double, double, 8);
 
   /* bv-u8-set! dst:8 idx:8 src:8
@@ -3509,42 +3527,42 @@ RTL_VM_NAME (SCM vm, SCM program, SCM *argv, size_t 
nargs_)
     NEXT (1);                                                           \
   } while (0)
 
-  VM_DEFINE_OP (118, bv_u8_set, "bv-u8-set!", OP1 (U8_U8_U8_U8))
+  VM_DEFINE_OP (119, bv_u8_set, "bv-u8-set!", OP1 (U8_U8_U8_U8))
     BV_FIXABLE_INT_SET (u8, u8, uint8, 0, SCM_T_UINT8_MAX, 1);
 
-  VM_DEFINE_OP (119, bv_s8_set, "bv-s8-set!", OP1 (U8_U8_U8_U8))
+  VM_DEFINE_OP (120, bv_s8_set, "bv-s8-set!", OP1 (U8_U8_U8_U8))
     BV_FIXABLE_INT_SET (s8, s8, int8, SCM_T_INT8_MIN, SCM_T_INT8_MAX, 1);
 
-  VM_DEFINE_OP (120, bv_u16_set, "bv-u16-set!", OP1 (U8_U8_U8_U8))
+  VM_DEFINE_OP (121, bv_u16_set, "bv-u16-set!", OP1 (U8_U8_U8_U8))
     BV_FIXABLE_INT_SET (u16, u16_native, uint16, 0, SCM_T_UINT16_MAX, 2);
 
-  VM_DEFINE_OP (121, bv_s16_set, "bv-s16-set!", OP1 (U8_U8_U8_U8))
+  VM_DEFINE_OP (122, bv_s16_set, "bv-s16-set!", OP1 (U8_U8_U8_U8))
     BV_FIXABLE_INT_SET (s16, s16_native, int16, SCM_T_INT16_MIN, 
SCM_T_INT16_MAX, 2);
 
-  VM_DEFINE_OP (122, bv_u32_set, "bv-u32-set!", OP1 (U8_U8_U8_U8))
+  VM_DEFINE_OP (123, bv_u32_set, "bv-u32-set!", OP1 (U8_U8_U8_U8))
 #if SIZEOF_VOID_P > 4
     BV_FIXABLE_INT_SET (u32, u32_native, uint32, 0, SCM_T_UINT32_MAX, 4);
 #else
     BV_INT_SET (u32, uint32, 4);
 #endif
 
-  VM_DEFINE_OP (123, bv_s32_set, "bv-s32-set!", OP1 (U8_U8_U8_U8))
+  VM_DEFINE_OP (124, bv_s32_set, "bv-s32-set!", OP1 (U8_U8_U8_U8))
 #if SIZEOF_VOID_P > 4
     BV_FIXABLE_INT_SET (s32, s32_native, int32, SCM_T_INT32_MIN, 
SCM_T_INT32_MAX, 4);
 #else
     BV_INT_SET (s32, int32, 4);
 #endif
 
-  VM_DEFINE_OP (124, bv_u64_set, "bv-u64-set!", OP1 (U8_U8_U8_U8))
+  VM_DEFINE_OP (125, bv_u64_set, "bv-u64-set!", OP1 (U8_U8_U8_U8))
     BV_INT_SET (u64, uint64, 8);
 
-  VM_DEFINE_OP (125, bv_s64_set, "bv-s64-set!", OP1 (U8_U8_U8_U8))
+  VM_DEFINE_OP (126, bv_s64_set, "bv-s64-set!", OP1 (U8_U8_U8_U8))
     BV_INT_SET (s64, int64, 8);
 
-  VM_DEFINE_OP (126, bv_f32_set, "bv-f32-set!", OP1 (U8_U8_U8_U8))
+  VM_DEFINE_OP (127, bv_f32_set, "bv-f32-set!", OP1 (U8_U8_U8_U8))
     BV_FLOAT_SET (f32, ieee_single, float, 4);
 
-  VM_DEFINE_OP (127, bv_f64_set, "bv-f64-set!", OP1 (U8_U8_U8_U8))
+  VM_DEFINE_OP (128, bv_f64_set, "bv-f64-set!", OP1 (U8_U8_U8_U8))
     BV_FLOAT_SET (f64, ieee_double, double, 8);
 
   END_DISPATCH_SWITCH;
diff --git a/libguile/vm.c b/libguile/vm.c
index c99431f..18580f2 100644
--- a/libguile/vm.c
+++ b/libguile/vm.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, 
Inc.
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -37,6 +37,8 @@
 #include "programs.h"
 #include "vm.h"
 
+#include "private-gc.h" /* scm_getenv_int */
+
 static int vm_default_engine = SCM_VM_REGULAR_ENGINE;
 
 /* Unfortunately we can't snarf these: snarfed things are only loaded up from
@@ -680,7 +682,17 @@ resolve_variable (SCM what, SCM module)
     }
 }
   
+#define VM_MIN_STACK_SIZE      (1024)
 #define VM_DEFAULT_STACK_SIZE  (64 * 1024)
+static size_t vm_stack_size = VM_DEFAULT_STACK_SIZE;
+
+static void
+initialize_default_stack_size (void)
+{
+  int size = scm_getenv_int ("GUILE_STACK_SIZE", vm_stack_size);
+  if (size >= VM_MIN_STACK_SIZE)
+    vm_stack_size = size;
+}
 
 #define VM_NAME   vm_regular_engine
 #define RTL_VM_NAME   rtl_vm_regular_engine
@@ -721,7 +733,7 @@ make_vm (void)
 
   vp = scm_gc_malloc (sizeof (struct scm_vm), "vm");
 
-  vp->stack_size  = VM_DEFAULT_STACK_SIZE;
+  vp->stack_size= vm_stack_size;
 
 #ifdef VM_ENABLE_PRECISE_STACK_GC_SCAN
   vp->stack_base = (SCM *)
@@ -1135,6 +1147,8 @@ scm_bootstrap_vm (void)
                             "scm_init_vm",
                             (scm_t_extension_init_func)scm_init_vm, NULL);
 
+  initialize_default_stack_size ();
+
   sym_vm_run = scm_from_latin1_symbol ("vm-run");
   sym_vm_error = scm_from_latin1_symbol ("vm-error");
   sym_keyword_argument_error = scm_from_latin1_symbol 
("keyword-argument-error");
diff --git a/libguile/vports.c b/libguile/vports.c
index a886e36..e726330 100644
--- a/libguile/vports.c
+++ b/libguile/vports.c
@@ -28,6 +28,8 @@
 #include "libguile/_scm.h"
 #include "libguile/eval.h"
 #include "libguile/chars.h"
+#include "libguile/ports.h"
+#include "libguile/ports-internal.h"
 #include "libguile/fports.h"
 #include "libguile/root.h"
 #include "libguile/strings.h"
@@ -86,15 +88,15 @@ sf_fill_input (SCM port)
 {
   SCM p = SCM_PACK (SCM_STREAM (port));
   SCM ans;
-  scm_t_port *pt;
+  scm_t_port_internal *pti;
 
   ans = scm_call_0 (SCM_SIMPLE_VECTOR_REF (p, 3)); /* get char.  */
   if (scm_is_false (ans) || SCM_EOF_OBJECT_P (ans))
     return EOF;
   SCM_ASSERT (SCM_CHARP (ans), ans, SCM_ARG1, "sf_fill_input");
-  pt = SCM_PTAB_ENTRY (port);    
+  pti = SCM_PORT_GET_INTERNAL (port);
 
-  if (pt->encoding_mode == SCM_PORT_ENCODING_MODE_LATIN1)
+  if (pti->encoding_mode == SCM_PORT_ENCODING_MODE_LATIN1)
     {
       scm_t_port *pt = SCM_PTAB_ENTRY (port);    
       
diff --git a/libguile/win32-socket.c b/libguile/win32-socket.c
deleted file mode 100644
index 825b4c4..0000000
--- a/libguile/win32-socket.c
+++ /dev/null
@@ -1,632 +0,0 @@
-/* Copyright (C) 2001, 2006 Free Software Foundation, Inc.
- * 
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of
- * the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA
- */
-
-
-
-
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
-
-#include "libguile/__scm.h"
-#include "libguile/modules.h"
-#include "libguile/numbers.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <errno.h>
-#include <limits.h>
-
-#ifndef PATH_MAX
-#define PATH_MAX 255
-#endif
-
-#include "win32-socket.h"
-
-/* Winsock API error description structure.  The error description is 
-   necessary because there is no error list available.  */
-typedef struct
-{
-  int error;         /* Error code.  */
-  char *str;         /* Error description.  */
-  int replace;       /* Possible error code replacement.  */
-  char *replace_str; /* Replacement symbol.  */
-  char *correct_str; /* Original symbol.  */
-}
-socket_error_t;
-
-#define FILE_ETC_SERVICES     "services"
-#define ENVIRON_ETC_SERVICES  "SERVICES"
-#define FILE_ETC_NETWORKS     "networks"
-#define ENVIRON_ETC_NETWORKS  "NETWORKS"
-#define FILE_ETC_PROTOCOLS    "protocol"
-#define ENVIRON_ETC_PROTOCOLS "PROTOCOLS"
-#define MAX_NAMLEN  256
-#define MAX_ALIASES 4
-
-/* Internal structure for a thread's M$-Windows servent interface.  */
-typedef struct
-{
-  FILE *fd;                            /* Current file.  */
-  char file[PATH_MAX];                 /* File name.  */
-  struct servent ent;                  /* Return value.  */
-  char name[MAX_NAMLEN];               /* Service name.  */
-  char proto[MAX_NAMLEN];              /* Protocol name.  */
-  char alias[MAX_ALIASES][MAX_NAMLEN]; /* All aliases.  */
-  char *aliases[MAX_ALIASES];          /* Alias pointers.  */
-  int port;                            /* Network port.  */
-}
-scm_i_servent_t;
-
-static scm_i_servent_t scm_i_servent;
-
-/* Internal structure for a thread's M$-Windows protoent interface.  */
-typedef struct
-{
-  FILE *fd;                            /* Current file.  */
-  char file[PATH_MAX];                 /* File name.  */
-  struct protoent ent;                 /* Return value.  */
-  char name[MAX_NAMLEN];               /* Protocol name.  */
-  char alias[MAX_ALIASES][MAX_NAMLEN]; /* All aliases.  */
-  char *aliases[MAX_ALIASES];          /* Alias pointers.  */
-  int proto;                           /* Protocol number.  */
-}
-scm_i_protoent_t;
-
-static scm_i_protoent_t scm_i_protoent;
-
-/* Define replacement symbols for most of the WSA* error codes.  */
-#ifndef EWOULDBLOCK
-# define EWOULDBLOCK     WSAEWOULDBLOCK
-#endif
-#ifndef EINPROGRESS
-# define EINPROGRESS     WSAEINPROGRESS
-#endif
-#ifndef EALREADY
-# define EALREADY        WSAEALREADY
-#endif
-#ifndef EDESTADDRREQ
-# define EDESTADDRREQ    WSAEDESTADDRREQ
-#endif
-#ifndef EMSGSIZE
-# define EMSGSIZE        WSAEMSGSIZE
-#endif
-#ifndef EPROTOTYPE
-# define EPROTOTYPE      WSAEPROTOTYPE
-#endif
-#ifndef ENOTSOCK
-# define ENOTSOCK        WSAENOTSOCK
-#endif
-#ifndef ENOPROTOOPT
-# define ENOPROTOOPT     WSAENOPROTOOPT
-#endif
-#ifndef EPROTONOSUPPORT
-# define EPROTONOSUPPORT WSAEPROTONOSUPPORT
-#endif
-#ifndef ESOCKTNOSUPPORT
-# define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
-#endif
-#ifndef EOPNOTSUPP
-# define EOPNOTSUPP      WSAEOPNOTSUPP
-#endif
-#ifndef EPFNOSUPPORT
-# define EPFNOSUPPORT    WSAEPFNOSUPPORT
-#endif
-#ifndef EAFNOSUPPORT
-# define EAFNOSUPPORT    WSAEAFNOSUPPORT
-#endif
-#ifndef EADDRINUSE
-# define EADDRINUSE      WSAEADDRINUSE
-#endif
-#ifndef EADDRNOTAVAIL
-# define EADDRNOTAVAIL   WSAEADDRNOTAVAIL
-#endif
-#ifndef ENETDOWN
-# define ENETDOWN        WSAENETDOWN
-#endif
-#ifndef ENETUNREACH
-# define ENETUNREACH     WSAENETUNREACH
-#endif
-#ifndef ENETRESET
-# define ENETRESET       WSAENETRESET
-#endif
-#ifndef ECONNABORTED
-# define ECONNABORTED    WSAECONNABORTED
-#endif
-#ifndef ECONNRESET
-# define ECONNRESET      WSAECONNRESET
-#endif
-#ifndef ENOBUFS
-# define ENOBUFS         WSAENOBUFS
-#endif
-#ifndef EISCONN
-# define EISCONN         WSAEISCONN
-#endif
-#ifndef ENOTCONN
-# define ENOTCONN        WSAENOTCONN
-#endif
-#ifndef ESHUTDOWN
-# define ESHUTDOWN       WSAESHUTDOWN
-#endif
-#ifndef ETOOMANYREFS
-# define ETOOMANYREFS    WSAETOOMANYREFS
-#endif
-#ifndef ETIMEDOUT
-# define ETIMEDOUT       WSAETIMEDOUT
-#endif
-#ifndef ECONNREFUSED
-# define ECONNREFUSED    WSAECONNREFUSED
-#endif
-#ifndef ELOOP
-# define ELOOP           WSAELOOP
-#endif
-#ifndef EHOSTDOWN
-# define EHOSTDOWN       WSAEHOSTDOWN
-#endif
-#ifndef EHOSTUNREACH
-# define EHOSTUNREACH    WSAEHOSTUNREACH
-#endif
-#ifndef EPROCLIM
-# define EPROCLIM        WSAEPROCLIM
-#endif
-#ifndef EUSERS
-# define EUSERS          WSAEUSERS
-#endif
-#ifndef EDQUOT
-# define EDQUOT          WSAEDQUOT
-#endif
-#ifndef ESTALE
-# define ESTALE          WSAESTALE
-#endif
-#ifndef EREMOTE
-# define EREMOTE         WSAEREMOTE
-#endif
-
-/* List of error structures.  */
-static socket_error_t socket_errno [] = {
-  /* 000 */ { 0, NULL, 0, NULL, NULL },
-  /* 001 */ { 0, NULL, 0, NULL, NULL },
-  /* 002 */ { 0, NULL, 0, NULL, NULL },
-  /* 003 */ { 0, NULL, 0, NULL, NULL },
-  /* 004 */ { WSAEINTR, "Interrupted function call", EINTR, NULL, "WSAEINTR" },
-  /* 005 */ { 0, NULL, 0, NULL, NULL },
-  /* 006 */ { 0, NULL, 0, NULL, NULL },
-  /* 007 */ { 0, NULL, 0, NULL, NULL },
-  /* 008 */ { 0, NULL, 0, NULL, NULL },
-  /* 009 */ { WSAEBADF, "Bad file number", EBADF, NULL, "WSAEBADF" },
-  /* 010 */ { 0, NULL, 0, NULL, NULL },
-  /* 011 */ { 0, NULL, 0, NULL, NULL },
-  /* 012 */ { 0, NULL, 0, NULL, NULL },
-  /* 013 */ { WSAEACCES, "Permission denied", EACCES, NULL, "WSAEACCES" },
-  /* 014 */ { WSAEFAULT, "Bad address", EFAULT, NULL, "WSAEFAULT" },
-  /* 015 */ { 0, NULL, 0, NULL, NULL },
-  /* 016 */ { 0, NULL, 0, NULL, NULL },
-  /* 017 */ { 0, NULL, 0, NULL, NULL },
-  /* 018 */ { 0, NULL, 0, NULL, NULL },
-  /* 019 */ { 0, NULL, 0, NULL, NULL },
-  /* 020 */ { 0, NULL, 0, NULL, NULL },
-  /* 021 */ { 0, NULL, 0, NULL, NULL },
-  /* 022 */ { WSAEINVAL, "Invalid argument", EINVAL, NULL, "WSAEINVAL" },
-  /* 023 */ { 0, NULL, 0, NULL, NULL },
-  /* 024 */ { WSAEMFILE, "Too many open files", EMFILE, NULL, "WSAEMFILE" },
-  /* 025 */ { 0, NULL, 0, NULL, NULL },
-  /* 026 */ { 0, NULL, 0, NULL, NULL },
-  /* 027 */ { 0, NULL, 0, NULL, NULL },
-  /* 028 */ { 0, NULL, 0, NULL, NULL },
-  /* 029 */ { 0, NULL, 0, NULL, NULL },
-  /* 030 */ { 0, NULL, 0, NULL, NULL },
-  /* 031 */ { 0, NULL, 0, NULL, NULL },
-  /* 032 */ { 0, NULL, 0, NULL, NULL },
-  /* 033 */ { 0, NULL, 0, NULL, NULL },
-  /* 034 */ { 0, NULL, 0, NULL, NULL },
-  /* 035 */ { WSAEWOULDBLOCK, "Resource temporarily unavailable", 
-             EWOULDBLOCK, "EWOULDBLOCK", "WSAEWOULDBLOCK" },
-  /* 036 */ { WSAEINPROGRESS, "Operation now in progress", 
-             EINPROGRESS, "EINPROGRESS", "WSAEINPROGRESS" },
-  /* 037 */ { WSAEALREADY, "Operation already in progress", 
-             EALREADY, "EALREADY", "WSAEALREADY" },
-  /* 038 */ { WSAENOTSOCK, "Socket operation on non-socket", 
-             ENOTSOCK, "ENOTSOCK", "WSAENOTSOCK"},
-  /* 039 */ { WSAEDESTADDRREQ, "Destination address required", 
-             EDESTADDRREQ, "EDESTADDRREQ", "WSAEDESTADDRREQ" },
-  /* 040 */ { WSAEMSGSIZE, "Message too long", 
-             EMSGSIZE, "EMSGSIZE", "WSAEMSGSIZE" },
-  /* 041 */ { WSAEPROTOTYPE, "Protocol wrong type for socket", 
-             EPROTOTYPE, "EPROTOTYPE", "WSAEPROTOTYPE" },
-  /* 042 */ { WSAENOPROTOOPT, "Bad protocol option", 
-             ENOPROTOOPT, "ENOPROTOOPT", "WSAENOPROTOOPT" },
-  /* 043 */ { WSAEPROTONOSUPPORT, "Protocol not supported", 
-             EPROTONOSUPPORT, "EPROTONOSUPPORT", "WSAEPROTONOSUPPORT" },
-  /* 044 */ { WSAESOCKTNOSUPPORT, "Socket type not supported",
-             ESOCKTNOSUPPORT, "ESOCKTNOSUPPORT", "WSAESOCKTNOSUPPORT" },
-  /* 045 */ { WSAEOPNOTSUPP, "Operation not supported",
-             EOPNOTSUPP, "EOPNOTSUPP", "WSAEOPNOTSUPP" },
-  /* 046 */ { WSAEPFNOSUPPORT, "Protocol family not supported",
-             EPFNOSUPPORT, "EPFNOSUPPORT", "WSAEPFNOSUPPORT" },
-  /* 047 */ { WSAEAFNOSUPPORT, 
-             "Address family not supported by protocol family", 
-             EAFNOSUPPORT, "EAFNOSUPPORT", "WSAEAFNOSUPPORT" },
-  /* 048 */ { WSAEADDRINUSE, "Address already in use", 
-             EADDRINUSE, "EADDRINUSE", "WSAEADDRINUSE" },
-  /* 049 */ { WSAEADDRNOTAVAIL, "Cannot assign requested address",
-             EADDRNOTAVAIL, "EADDRNOTAVAIL", "WSAEADDRNOTAVAIL" },
-  /* 050 */ { WSAENETDOWN, "Network is down",
-             ENETDOWN, "ENETDOWN", "WSAENETDOWN" },
-  /* 051 */ { WSAENETUNREACH, "Network is unreachable",
-             ENETUNREACH, "ENETUNREACH", "WSAENETUNREACH" },
-  /* 052 */ { WSAENETRESET, "Network dropped connection on reset",
-             ENETRESET, "ENETRESET", "WSAENETRESET" },
-  /* 053 */ { WSAECONNABORTED, "Software caused connection abort",
-             ECONNABORTED, "ECONNABORTED", "WSAECONNABORTED" },
-  /* 054 */ { WSAECONNRESET, "Connection reset by peer",
-             ECONNRESET, "ECONNRESET", "WSAECONNRESET" },
-  /* 055 */ { WSAENOBUFS, "No buffer space available",
-             ENOBUFS, "ENOBUFS", "WSAENOBUFS" },
-  /* 056 */ { WSAEISCONN, "Socket is already connected",
-             EISCONN, "EISCONN", "WSAEISCONN" },
-  /* 057 */ { WSAENOTCONN, "Socket is not connected",
-             ENOTCONN, "ENOTCONN", "WSAENOTCONN" },
-  /* 058 */ { WSAESHUTDOWN, "Cannot send after socket shutdown",
-             ESHUTDOWN, "ESHUTDOWN", "WSAESHUTDOWN" },
-  /* 059 */ { WSAETOOMANYREFS, "Too many references; can't splice",
-             ETOOMANYREFS, "ETOOMANYREFS", "WSAETOOMANYREFS" },
-  /* 060 */ { WSAETIMEDOUT, "Connection timed out",
-             ETIMEDOUT, "ETIMEDOUT", "WSAETIMEDOUT" },
-  /* 061 */ { WSAECONNREFUSED, "Connection refused",
-             ECONNREFUSED, "ECONNREFUSED", "WSAECONNREFUSED" },
-  /* 062 */ { WSAELOOP, "Too many levels of symbolic links",
-             ELOOP, "ELOOP", "WSAELOOP" },
-  /* 063 */ { WSAENAMETOOLONG, "File name too long",
-             ENAMETOOLONG, NULL, "WSAENAMETOOLONG" },
-  /* 064 */ { WSAEHOSTDOWN, "Host is down",
-             EHOSTDOWN, "EHOSTDOWN", "WSAEHOSTDOWN" },
-  /* 065 */ { WSAEHOSTUNREACH, "No route to host",
-             EHOSTUNREACH, "EHOSTUNREACH", "WSAEHOSTUNREACH" },
-  /* 066 */ { WSAENOTEMPTY, "Directory not empty",
-             ENOTEMPTY, NULL, "WSAENOTEMPTY" },
-  /* 067 */ { WSAEPROCLIM, "Too many processes",
-             EPROCLIM, "EPROCLIM", "WSAEPROCLIM" },
-  /* 068 */ { WSAEUSERS, "Too many users",
-             EUSERS, "EUSERS", "WSAEUSERS" },
-  /* 069 */ { WSAEDQUOT, "Disc quota exceeded",
-             EDQUOT, "EDQUOT", "WSAEDQUOT" },
-  /* 070 */ { WSAESTALE, "Stale NFS file handle",
-             ESTALE, "ESTALE", "WSAESTALE" },
-  /* 071 */ { WSAEREMOTE, "Too many levels of remote in path",
-             EREMOTE, "EREMOTE", "WSAEREMOTE" },
-  /* 072 */ { 0, NULL, 0, NULL, NULL },
-  /* 073 */ { 0, NULL, 0, NULL, NULL },
-  /* 074 */ { 0, NULL, 0, NULL, NULL },
-  /* 075 */ { 0, NULL, 0, NULL, NULL },
-  /* 076 */ { 0, NULL, 0, NULL, NULL },
-  /* 077 */ { 0, NULL, 0, NULL, NULL },
-  /* 078 */ { 0, NULL, 0, NULL, NULL },
-  /* 079 */ { 0, NULL, 0, NULL, NULL },
-  /* 080 */ { 0, NULL, 0, NULL, NULL },
-  /* 081 */ { 0, NULL, 0, NULL, NULL },
-  /* 082 */ { 0, NULL, 0, NULL, NULL },
-  /* 083 */ { 0, NULL, 0, NULL, NULL },
-  /* 084 */ { 0, NULL, 0, NULL, NULL },
-  /* 085 */ { 0, NULL, 0, NULL, NULL },
-  /* 086 */ { 0, NULL, 0, NULL, NULL },
-  /* 087 */ { 0, NULL, 0, NULL, NULL },
-  /* 088 */ { 0, NULL, 0, NULL, NULL },
-  /* 089 */ { 0, NULL, 0, NULL, NULL },
-  /* 090 */ { 0, NULL, 0, NULL, NULL },
-  /* 091 */ { WSASYSNOTREADY, "Network subsystem is unavailable",
-             0, NULL, "WSASYSNOTREADY" },
-  /* 092 */ { WSAVERNOTSUPPORTED, "WINSOCK.DLL version out of range", 
-             0, NULL, "WSAVERNOTSUPPORTED" },
-  /* 093 */ { WSANOTINITIALISED, "Successful WSAStartup not yet performed", 
-             0, NULL, "WSANOTINITIALISED" },
-  /* 094 */ { 0, NULL, 0, NULL, NULL },
-  /* 095 */ { 0, NULL, 0, NULL, NULL },
-  /* 096 */ { 0, NULL, 0, NULL, NULL },
-  /* 097 */ { 0, NULL, 0, NULL, NULL },
-  /* 098 */ { 0, NULL, 0, NULL, NULL },
-  /* 099 */ { 0, NULL, 0, NULL, NULL },
-  /* 100 */ { 0, NULL, 0, NULL, NULL },
-  /* 101 */ { WSAEDISCON, "Graceful shutdown in progress",
-             0, NULL, "WSAEDISCON" },
-  /* 102 */ { WSAENOMORE, "No more services", 
-             0, NULL, "WSAENOMORE" },
-  /* 103 */ { WSAECANCELLED, "Service lookup cancelled",
-             0, NULL, "WSAECANCELLED" },
-  /* 104 */ { WSAEINVALIDPROCTABLE, "Invalid procedure call table", 
-             0, NULL, "WSAEINVALIDPROCTABLE" },
-  /* 105 */ { WSAEINVALIDPROVIDER, "Invalid service provider",
-             0, NULL, "WSAEINVALIDPROVIDER" },
-  /* 106 */ { WSAEPROVIDERFAILEDINIT, "Service provider failure", 
-             0, NULL, "WSAEPROVIDERFAILEDINIT" },
-  /* 107 */ { WSASYSCALLFAILURE, "System call failed",
-             0, NULL, "WSASYSCALLFAILURE" },
-  /* 108 */ { WSASERVICE_NOT_FOUND, "No such service",
-             0, NULL, "WSASERVICE_NOT_FOUND" },
-  /* 109 */ { WSATYPE_NOT_FOUND, "Class not found", 
-             0, NULL, "WSATYPE_NOT_FOUND" },
-  /* 110 */ { WSA_E_NO_MORE, "No more services",
-             0, NULL, "WSA_E_NO_MORE" },
-  /* 111 */ { WSA_E_CANCELLED, "Service lookup cancelled", 
-             0, NULL, "WSA_E_CANCELLED" },
-  /* 112 */ { WSAEREFUSED, "Database query refused", 
-             0, NULL, "WSAEREFUSED" },
-  /* end */ { -1, NULL, -1, NULL, NULL }
-};
-
-/* Extended list of error structures.  */
-static socket_error_t socket_h_errno [] = {
-  /* 000 */ { 0, NULL, 0, NULL, NULL },
-  /* 001 */ { WSAHOST_NOT_FOUND, "Host not found",
-             HOST_NOT_FOUND, "HOST_NOT_FOUND", "WSAHOST_NOT_FOUND" },
-  /* 002 */ { WSATRY_AGAIN, "Non-authoritative host not found",
-             TRY_AGAIN, "TRY_AGAIN", "WSATRY_AGAIN" },
-  /* 003 */ { WSANO_RECOVERY, "This is a non-recoverable error", 
-             NO_RECOVERY, "NO_RECOVERY", "WSANO_RECOVERY" },
-  /* 004 */ { WSANO_DATA, "Valid name, no data record of requested type",
-             NO_DATA, "NO_DATA", "WSANO_DATA" },
-  /* 005 */ { WSANO_ADDRESS, "No address, look for MX record",
-             NO_ADDRESS, "NO_ADDRESS", "WSANO_ADDRESS" },
-  /* end */ { -1, NULL, -1, NULL, NULL }
-};
-
-/* Returns the result of @code{WSAGetLastError()}.  */
-int
-scm_i_socket_errno (void)
-{
-  return WSAGetLastError ();
-}
-
-/* Returns a valid error message for Winsock-API error codes obtained via
-   @code{WSAGetLastError()} or NULL otherwise.  */
-char *
-scm_i_socket_strerror (int error)
-{
-  if (error >= WSABASEERR && error <= (WSABASEERR + 112))
-    return socket_errno[error - WSABASEERR].str;
-  else if (error >= (WSABASEERR + 1000) && error <= (WSABASEERR + 1005))
-    return socket_h_errno[error - (WSABASEERR + 1000)].str;
-  return NULL;
-}
-
-/* Constructs a valid filename for the given file @var{file} in the M$-Windows
-   directory.  This is usually the default location for the network files.  */
-char *
-scm_i_socket_filename (char *file)
-{
-  static char dir[PATH_MAX];
-  int len = PATH_MAX;
-
-  len = GetWindowsDirectory (dir, len);
-  if (dir[len - 1] != '\\')
-    strcat (dir, "\\");
-  strcat (dir, file);
-  return dir;
-}
-
-/* Removes comments and white spaces at end of line and returns a pointer
-   to the end of the line.  */
-static char *
-scm_i_socket_uncomment (char *line)
-{
-  char *end;
-
-  if ((end = strchr (line, '#')) != NULL)
-    *end-- = '\0';
-  else
-    {
-      end = line + strlen (line) - 1;
-      while (end > line && (*end == '\r' || *end == '\n'))
-       *end-- = '\0';
-    }
-  while (end > line && isspace ((int) (*end)))
-    *end-- = '\0';
-
-  return end;
-}
-
-/* The getservent() function reads the next line from the file `/etc/services'
-   and returns a structure servent containing the broken out fields from the
-   line.  The `/etc/services' file is opened if necessary. */
-struct servent *
-getservent (void)
-{
-  char line[MAX_NAMLEN], *end, *p;
-  int done = 0, i, n, a;
-  struct servent *e = NULL;
-
-  /* Ensure a open file.  */
-  if (scm_i_servent.fd == NULL || feof (scm_i_servent.fd))
-    {
-      setservent (1);
-      if (scm_i_servent.fd == NULL)
-       return NULL;
-    }
-
-  while (!done)
-    {
-      /* Get new line.  */
-      if (fgets (line, MAX_NAMLEN, scm_i_servent.fd) != NULL)
-       {
-         end = scm_i_socket_uncomment (line);
-
-         /* Scan the line.  */
-         if ((i = sscanf (line, "%s %d/%s%n", 
-                          scm_i_servent.name,
-                          &scm_i_servent.port, 
-                          scm_i_servent.proto, &n)) != 3)
-           continue;
-
-         /* Scan the remaining aliases.  */
-         p = line + n;
-         for (a = 0; a < MAX_ALIASES && p < end && i != -1 && n > 1; 
-              a++, p += n)
-           i = sscanf (p, "%s%n", scm_i_servent.alias[a], &n);
-
-         /* Prepare the return value.  */
-         e = &scm_i_servent.ent;
-         e->s_name = scm_i_servent.name;
-         e->s_port = htons (scm_i_servent.port);
-         e->s_proto = scm_i_servent.proto;
-         e->s_aliases = scm_i_servent.aliases;
-         scm_i_servent.aliases[a] = NULL;
-         while (a--)
-           scm_i_servent.aliases[a] = scm_i_servent.alias[a];
-         done = 1;
-       }
-      else
-       break;
-    }
-  return done ? e : NULL;
-}
-
-/* The setservent() function opens and rewinds the `/etc/services' file.  
-   This file can be set from outside with an environment variable specifying
-   the file name.  */
-void
-setservent (int stayopen)
-{
-  char *file = NULL;
-
-  endservent ();
-  if ((file = getenv (ENVIRON_ETC_SERVICES)) != NULL)
-    strcpy (scm_i_servent.file, file);
-  else if ((file = scm_i_socket_filename (FILE_ETC_SERVICES)) != NULL)
-    strcpy (scm_i_servent.file, file);
-  scm_i_servent.fd = fopen (scm_i_servent.file, "rt");
-}
-
-/* The endservent() function closes the `/etc/services' file.  */
-void
-endservent (void)
-{
-  if (scm_i_servent.fd != NULL)
-    {
-      fclose (scm_i_servent.fd);
-      scm_i_servent.fd = NULL;
-    }
-}
-
-/* The getprotoent() function reads the next line from the file
-   `/etc/protocols' and returns a structure protoent containing the broken
-   out fields from the line. The `/etc/protocols' file is opened if 
-   necessary.  */
-struct protoent *
-getprotoent (void)
-{
-  char line[MAX_NAMLEN], *end, *p;
-  int done = 0, i, n, a;
-  struct protoent *e = NULL;
-
-  /* Ensure a open file.  */
-  if (scm_i_protoent.fd == NULL || feof (scm_i_protoent.fd))
-    {
-      setprotoent (1);
-      if (scm_i_protoent.fd == NULL)
-       return NULL;
-    }
-
-  while (!done)
-    {
-      /* Get new line.  */
-      if (fgets (line, MAX_NAMLEN, scm_i_protoent.fd) != NULL)
-       {
-         end = scm_i_socket_uncomment (line);
-
-         /* Scan the line.  */
-         if ((i = sscanf (line, "%s %d%n", 
-                          scm_i_protoent.name,
-                          &scm_i_protoent.proto, &n)) != 2)
-           continue;
-
-         /* Scan the remaining aliases.  */
-         p = line + n;
-         for (a = 0; a < MAX_ALIASES && p < end && i != -1 && n > 1; 
-              a++, p += n)
-           i = sscanf (p, "%s%n", scm_i_protoent.alias[a], &n);
-
-         /* Prepare the return value.  */
-         e = &scm_i_protoent.ent;
-         e->p_name = scm_i_protoent.name;
-         e->p_proto = scm_i_protoent.proto;
-         e->p_aliases = scm_i_protoent.aliases;
-         scm_i_protoent.aliases[a] = NULL;
-         while (a--)
-           scm_i_protoent.aliases[a] = scm_i_protoent.alias[a];
-         done = 1;
-       }
-      else
-       break;
-    }
-  return done ? e : NULL;
-}
-
-/* The setprotoent() function opens and rewinds the `/etc/protocols' file. 
-   As in setservent() the user can modify the location of the file using
-   an environment variable.  */
-void 
-setprotoent (int stayopen)
-{
-  char *file = NULL;
-
-  endprotoent ();
-  if ((file = getenv (ENVIRON_ETC_PROTOCOLS)) != NULL)
-    strcpy (scm_i_protoent.file, file);
-  else if ((file = scm_i_socket_filename (FILE_ETC_PROTOCOLS)) != NULL)
-    strcpy (scm_i_protoent.file, file);
-  scm_i_protoent.fd = fopen (scm_i_protoent.file, "rt");
-}
-
-/* The endprotoent() function closes `/etc/protocols'.  */
-void
-endprotoent (void)
-{
-  if (scm_i_protoent.fd != NULL)
-    {
-      fclose (scm_i_protoent.fd);
-      scm_i_protoent.fd = NULL;
-    }
-}
-
-/* Define both the original and replacement error symbol is possible.  Thus
-   the user is able to check symbolic errors after unsuccessful networking
-   function calls.  */
-static void
-scm_socket_symbols_Win32 (socket_error_t * e)
-{
-  while (e->error != -1)
-    {
-      if (e->error)
-       {
-         if (e->correct_str)
-           scm_c_define (e->correct_str, scm_from_int (e->error));
-         if (e->replace && e->replace_str)
-           scm_c_define (e->replace_str, scm_from_int (e->replace));
-       }
-      e++;
-    }
-}
-
-/* Initialize Winsock API under M$-Windows.  */
-void
-scm_i_init_socket_Win32 (void)
-{
-  scm_socket_symbols_Win32 (socket_errno);
-  scm_socket_symbols_Win32 (socket_h_errno);
-}
diff --git a/libguile/win32-socket.h b/libguile/win32-socket.h
deleted file mode 100644
index 4ab9b94..0000000
--- a/libguile/win32-socket.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* classes: h_files */
-
-#ifndef SCM_WIN32_SOCKET_H
-#define SCM_WIN32_SOCKET_H
-
-/* Copyright (C) 2001, 2006 Free Software Foundation, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of
- * the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA
- */
-
-#include "libguile/__scm.h"
-
-#ifdef SCM_HAVE_WINSOCK2_H
-# include <winsock2.h>
-#endif
-
-int scm_i_socket_errno (void);
-char * scm_i_socket_strerror (int error);
-void scm_i_init_socket_Win32 (void);
-char * scm_i_socket_filename (char *file);
-
-struct servent * getservent (void);
-void setservent (int stayopen);
-void endservent (void);
-struct protoent * getprotoent (void);
-void setprotoent (int stayopen);
-void endprotoent (void);
-
-#endif /* SCM_WIN32_SOCKET_H */
diff --git a/m4/00gnulib.m4 b/m4/00gnulib.m4
index d978cb8..d4ad759 100644
--- a/m4/00gnulib.m4
+++ b/m4/00gnulib.m4
@@ -1,5 +1,5 @@
 # 00gnulib.m4 serial 2
-dnl Copyright (C) 2009-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2009-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/absolute-header.m4 b/m4/absolute-header.m4
index 8a91d20..89ff5be 100644
--- a/m4/absolute-header.m4
+++ b/m4/absolute-header.m4
@@ -1,5 +1,5 @@
 # absolute-header.m4 serial 16
-dnl Copyright (C) 2006-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2006-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/alloca.m4 b/m4/alloca.m4
index 656924b..270abd0 100644
--- a/m4/alloca.m4
+++ b/m4/alloca.m4
@@ -1,5 +1,5 @@
 # alloca.m4 serial 14
-dnl Copyright (C) 2002-2004, 2006-2007, 2009-2012 Free Software Foundation,
+dnl Copyright (C) 2002-2004, 2006-2007, 2009-2013 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
diff --git a/m4/arpa_inet_h.m4 b/m4/arpa_inet_h.m4
index 36915d1..ea69af5 100644
--- a/m4/arpa_inet_h.m4
+++ b/m4/arpa_inet_h.m4
@@ -1,5 +1,5 @@
 # arpa_inet_h.m4 serial 13
-dnl Copyright (C) 2006, 2008-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2006, 2008-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/autobuild.m4 b/m4/autobuild.m4
index 284dc60..3147b5b 100644
--- a/m4/autobuild.m4
+++ b/m4/autobuild.m4
@@ -1,5 +1,5 @@
 # autobuild.m4 serial 7
-dnl Copyright (C) 2004, 2006-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2004, 2006-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/btowc.m4 b/m4/btowc.m4
index e565321..978a06e 100644
--- a/m4/btowc.m4
+++ b/m4/btowc.m4
@@ -1,5 +1,5 @@
 # btowc.m4 serial 10
-dnl Copyright (C) 2008-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2008-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/byteswap.m4 b/m4/byteswap.m4
index f3b7ec9..7566903 100644
--- a/m4/byteswap.m4
+++ b/m4/byteswap.m4
@@ -1,5 +1,5 @@
 # byteswap.m4 serial 4
-dnl Copyright (C) 2005, 2007, 2009-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2005, 2007, 2009-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/canonicalize.m4 b/m4/canonicalize.m4
index ea51ac4..cef3124 100644
--- a/m4/canonicalize.m4
+++ b/m4/canonicalize.m4
@@ -1,6 +1,6 @@
 # canonicalize.m4 serial 26
 
-dnl Copyright (C) 2003-2007, 2009-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2003-2007, 2009-2013 Free Software Foundation, Inc.
 
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
diff --git a/m4/ceil.m4 b/m4/ceil.m4
index 890517b..c617561 100644
--- a/m4/ceil.m4
+++ b/m4/ceil.m4
@@ -1,5 +1,5 @@
 # ceil.m4 serial 9
-dnl Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/check-math-lib.m4 b/m4/check-math-lib.m4
index 4f370eb..77570f4 100644
--- a/m4/check-math-lib.m4
+++ b/m4/check-math-lib.m4
@@ -1,5 +1,5 @@
 # check-math-lib.m4 serial 4
-dnl Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/clock_time.m4 b/m4/clock_time.m4
index fb3a17a..767a1be 100644
--- a/m4/clock_time.m4
+++ b/m4/clock_time.m4
@@ -1,5 +1,5 @@
 # clock_time.m4 serial 10
-dnl Copyright (C) 2002-2006, 2009-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/close.m4 b/m4/close.m4
index 379e70d..bccd981 100644
--- a/m4/close.m4
+++ b/m4/close.m4
@@ -1,5 +1,5 @@
 # close.m4 serial 8
-dnl Copyright (C) 2008-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2008-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/codeset.m4 b/m4/codeset.m4
index cf53d24..c2761be 100644
--- a/m4/codeset.m4
+++ b/m4/codeset.m4
@@ -1,5 +1,5 @@
 # codeset.m4 serial 5 (gettext-0.18.2)
-dnl Copyright (C) 2000-2002, 2006, 2008-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2000-2002, 2006, 2008-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/configmake.m4 b/m4/configmake.m4
index 8c82371..823ffc0 100644
--- a/m4/configmake.m4
+++ b/m4/configmake.m4
@@ -1,5 +1,5 @@
 # configmake.m4 serial 1
-dnl Copyright (C) 2010-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2010-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/dirent_h.m4 b/m4/dirent_h.m4
index f6c0fa7..54c1663 100644
--- a/m4/dirent_h.m4
+++ b/m4/dirent_h.m4
@@ -1,5 +1,5 @@
 # dirent_h.m4 serial 16
-dnl Copyright (C) 2008-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2008-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/dirfd.m4 b/m4/dirfd.m4
index fc475d7..39bc789 100644
--- a/m4/dirfd.m4
+++ b/m4/dirfd.m4
@@ -2,7 +2,7 @@
 
 dnl Find out how to get the file descriptor associated with an open DIR*.
 
-# Copyright (C) 2001-2006, 2008-2012 Free Software Foundation, Inc.
+# Copyright (C) 2001-2006, 2008-2013 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
diff --git a/m4/dirname.m4 b/m4/dirname.m4
index 65639ec..5897a2a 100644
--- a/m4/dirname.m4
+++ b/m4/dirname.m4
@@ -1,5 +1,5 @@
 #serial 10   -*- autoconf -*-
-dnl Copyright (C) 2002-2006, 2009-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/double-slash-root.m4 b/m4/double-slash-root.m4
index 1e03751..bd6f867 100644
--- a/m4/double-slash-root.m4
+++ b/m4/double-slash-root.m4
@@ -1,5 +1,5 @@
 # double-slash-root.m4 serial 4   -*- Autoconf -*-
-dnl Copyright (C) 2006, 2008-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2006, 2008-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/dup2.m4 b/m4/dup2.m4
new file mode 100644
index 0000000..269cfdc
--- /dev/null
+++ b/m4/dup2.m4
@@ -0,0 +1,84 @@
+#serial 19
+dnl Copyright (C) 2002, 2005, 2007, 2009-2013 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_DUP2],
+[
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  m4_ifdef([gl_FUNC_DUP2_OBSOLETE], [
+    AC_CHECK_FUNCS_ONCE([dup2])
+    if test $ac_cv_func_dup2 = no; then
+      HAVE_DUP2=0
+    fi
+  ], [
+    AC_DEFINE([HAVE_DUP2], [1], [Define to 1 if you have the 'dup2' function.])
+  ])
+  if test $HAVE_DUP2 = 1; then
+    AC_CACHE_CHECK([whether dup2 works], [gl_cv_func_dup2_works],
+      [AC_RUN_IFELSE([
+         AC_LANG_PROGRAM([[#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>]],
+           [int result = 0;
+#ifdef FD_CLOEXEC
+            if (fcntl (1, F_SETFD, FD_CLOEXEC) == -1)
+              result |= 1;
+#endif
+            if (dup2 (1, 1) == 0)
+              result |= 2;
+#ifdef FD_CLOEXEC
+            if (fcntl (1, F_GETFD) != FD_CLOEXEC)
+              result |= 4;
+#endif
+            close (0);
+            if (dup2 (0, 0) != -1)
+              result |= 8;
+            /* Many gnulib modules require POSIX conformance of EBADF.  */
+            if (dup2 (2, 1000000) == -1 && errno != EBADF)
+              result |= 16;
+            /* Flush out a cygwin core dump.  */
+            if (dup2 (2, -1) != -1 || errno != EBADF)
+              result |= 32;
+            return result;
+           ])
+        ],
+        [gl_cv_func_dup2_works=yes], [gl_cv_func_dup2_works=no],
+        [case "$host_os" in
+           mingw*) # on this platform, dup2 always returns 0 for success
+             gl_cv_func_dup2_works="guessing no" ;;
+           cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
+             gl_cv_func_dup2_works="guessing no" ;;
+           linux*) # On linux between 2008-07-27 and 2009-05-11, dup2 of a
+                   # closed fd may yield -EBADF instead of -1 / errno=EBADF.
+             gl_cv_func_dup2_works="guessing no" ;;
+           freebsd*) # on FreeBSD 6.1, dup2(1,1000000) gives EMFILE, not EBADF.
+             gl_cv_func_dup2_works="guessing no" ;;
+           haiku*) # on Haiku alpha 2, dup2(1, 1) resets FD_CLOEXEC.
+             gl_cv_func_dup2_works="guessing no" ;;
+           *) gl_cv_func_dup2_works="guessing yes" ;;
+         esac])
+      ])
+    case "$gl_cv_func_dup2_works" in
+      *yes) ;;
+      *)
+        REPLACE_DUP2=1
+        ;;
+    esac
+  fi
+  dnl Replace dup2() for supporting the gnulib-defined fchdir() function,
+  dnl to keep fchdir's bookkeeping up-to-date.
+  m4_ifdef([gl_FUNC_FCHDIR], [
+    gl_TEST_FCHDIR
+    if test $HAVE_FCHDIR = 0; then
+      if test $HAVE_DUP2 = 1; then
+        REPLACE_DUP2=1
+      fi
+    fi
+  ])
+])
+
+# Prerequisites of lib/dup2.c.
+AC_DEFUN([gl_PREREQ_DUP2], [])
diff --git a/m4/duplocale.m4 b/m4/duplocale.m4
index 6096f5c..9ef894c 100644
--- a/m4/duplocale.m4
+++ b/m4/duplocale.m4
@@ -1,5 +1,5 @@
 # duplocale.m4 serial 7
-dnl Copyright (C) 2009-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2009-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/eealloc.m4 b/m4/eealloc.m4
index 9e5df45..c640ec1 100644
--- a/m4/eealloc.m4
+++ b/m4/eealloc.m4
@@ -1,5 +1,5 @@
 # eealloc.m4 serial 3
-dnl Copyright (C) 2003, 2009-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2003, 2009-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/environ.m4 b/m4/environ.m4
index 8eb57c9..593a33e 100644
--- a/m4/environ.m4
+++ b/m4/environ.m4
@@ -1,5 +1,5 @@
 # environ.m4 serial 6
-dnl Copyright (C) 2001-2004, 2006-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2001-2004, 2006-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/errno_h.m4 b/m4/errno_h.m4
index 4e33ba8..c813ea5 100644
--- a/m4/errno_h.m4
+++ b/m4/errno_h.m4
@@ -1,5 +1,5 @@
 # errno_h.m4 serial 12
-dnl Copyright (C) 2004, 2006, 2008-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2004, 2006, 2008-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/exponentd.m4 b/m4/exponentd.m4
index 0ae4ccf..09df468 100644
--- a/m4/exponentd.m4
+++ b/m4/exponentd.m4
@@ -1,5 +1,5 @@
 # exponentd.m4 serial 3
-dnl Copyright (C) 2007-2008, 2010-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2007-2008, 2010-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/exponentf.m4 b/m4/exponentf.m4
index 94d1167..55a04e6 100644
--- a/m4/exponentf.m4
+++ b/m4/exponentf.m4
@@ -1,5 +1,5 @@
 # exponentf.m4 serial 2
-dnl Copyright (C) 2007-2008, 2010-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2007-2008, 2010-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/exponentl.m4 b/m4/exponentl.m4
index a7cd13b..f877cf1 100644
--- a/m4/exponentl.m4
+++ b/m4/exponentl.m4
@@ -1,5 +1,5 @@
 # exponentl.m4 serial 3
-dnl Copyright (C) 2007-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2007-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/extensions.m4 b/m4/extensions.m4
index 6d17d8a..07ba376 100644
--- a/m4/extensions.m4
+++ b/m4/extensions.m4
@@ -1,14 +1,14 @@
-# serial 12  -*- Autoconf -*-
+# serial 13  -*- Autoconf -*-
 # Enable extensions on systems that normally disable them.
 
-# Copyright (C) 2003, 2006-2012 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2006-2013 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
 # This definition of AC_USE_SYSTEM_EXTENSIONS is stolen from CVS
 # Autoconf.  Perhaps we can remove this once we can assume Autoconf
-# 2.62 or later everywhere, but since CVS Autoconf mutates rapidly
+# 2.70 or later everywhere, but since Autoconf mutates rapidly
 # enough in this area it's likely we'll need to redefine
 # AC_USE_SYSTEM_EXTENSIONS for quite some time.
 
@@ -30,6 +30,7 @@
 # ------------------------
 # Enable extensions on systems that normally disable them,
 # typically due to standards-conformance issues.
+#
 # Remember that #undef in AH_VERBATIM gets replaced with #define by
 # AC_DEFINE.  The goal here is to define all known feature-enabling
 # macros, then, if reports of conflicts are made, disable macros that
@@ -38,8 +39,6 @@ AC_DEFUN_ONCE([AC_USE_SYSTEM_EXTENSIONS],
 [AC_BEFORE([$0], [AC_COMPILE_IFELSE])dnl
 AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
 
-  AC_REQUIRE([AC_CANONICAL_HOST])
-
   AC_CHECK_HEADER([minix/config.h], [MINIX=yes], [MINIX=])
   if test "$MINIX" = yes; then
     AC_DEFINE([_POSIX_SOURCE], [1],
@@ -50,24 +49,18 @@ AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
        except with this defined.])
     AC_DEFINE([_MINIX], [1],
       [Define to 1 if on MINIX.])
+    AC_DEFINE([_NETBSD_SOURCE], [1],
+      [Define to 1 to make NetBSD features available.  MINIX 3 needs this.])
   fi
 
-  dnl HP-UX 11.11 defines mbstate_t only if _XOPEN_SOURCE is defined to 500,
-  dnl regardless of whether the flags -Ae or _D_HPUX_SOURCE=1 are already
-  dnl provided.
-  case "$host_os" in
-    hpux*)
-      AC_DEFINE([_XOPEN_SOURCE], [500],
-        [Define to 500 only on HP-UX.])
-      ;;
-  esac
-
-  AH_VERBATIM([__EXTENSIONS__],
+dnl Use a different key than __EXTENSIONS__, as that name broke existing
+dnl configure.ac when using autoheader 2.62.
+  AH_VERBATIM([USE_SYSTEM_EXTENSIONS],
 [/* Enable extensions on AIX 3, Interix.  */
 #ifndef _ALL_SOURCE
 # undef _ALL_SOURCE
 #endif
-/* Enable general extensions on Mac OS X.  */
+/* Enable general extensions on OS X.  */
 #ifndef _DARWIN_C_SOURCE
 # undef _DARWIN_C_SOURCE
 #endif
@@ -83,6 +76,12 @@ AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
 #ifndef _TANDEM_SOURCE
 # undef _TANDEM_SOURCE
 #endif
+/* Enable X/Open extensions if necessary.  HP-UX 11.11 defines
+   mbstate_t only if _XOPEN_SOURCE is defined to 500, regardless of
+   whether compiling with -Ae or -D_HPUX_SOURCE=1.  */
+#ifndef _XOPEN_SOURCE
+# undef _XOPEN_SOURCE
+#endif
 /* Enable general extensions on Solaris.  */
 #ifndef __EXTENSIONS__
 # undef __EXTENSIONS__
@@ -103,6 +102,22 @@ AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
   AC_DEFINE([_GNU_SOURCE])
   AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
   AC_DEFINE([_TANDEM_SOURCE])
+  AC_CACHE_CHECK([whether _XOPEN_SOURCE should be defined],
+    [ac_cv_should_define__xopen_source],
+    [ac_cv_should_define__xopen_source=no
+     AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM([[
+          #include <wchar.h>
+          mbstate_t x;]])],
+       [],
+       [AC_COMPILE_IFELSE(
+          [AC_LANG_PROGRAM([[
+             #define _XOPEN_SOURCE 500
+             #include <wchar.h>
+             mbstate_t x;]])],
+          [ac_cv_should_define__xopen_source=yes])])])
+  test $ac_cv_should_define__xopen_source = yes &&
+    AC_DEFINE([_XOPEN_SOURCE], [500])
 ])# AC_USE_SYSTEM_EXTENSIONS
 
 # gl_USE_SYSTEM_EXTENSIONS
diff --git a/m4/extern-inline.m4 b/m4/extern-inline.m4
index 600c8d3..5880d4f 100644
--- a/m4/extern-inline.m4
+++ b/m4/extern-inline.m4
@@ -1,13 +1,12 @@
 dnl 'extern inline' a la ISO C99.
 
-dnl Copyright 2012 Free Software Foundation, Inc.
+dnl Copyright 2012-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_EXTERN_INLINE],
 [
-  AC_REQUIRE([AC_C_INLINE])
   AH_VERBATIM([extern_inline],
 [/* _GL_INLINE is a portable alternative to ISO C99 plain 'inline'.
    _GL_EXTERN_INLINE is a portable alternative to 'extern inline'.
@@ -17,13 +16,19 @@ AC_DEFUN([gl_EXTERN_INLINE],
      when FOO is an inline function in the header; see
      <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113>.
    _GL_INLINE_HEADER_END contains useful stuff to put
-     in the same include file, after uses of _GL_INLINE.  */
-#if (__GNUC__ \
-     ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \
-     : 199901L <= __STDC_VERSION__)
+     in the same include file, after uses of _GL_INLINE.
+
+   Suppress the use of extern inline on Apple's platforms,
+   as Libc-825.25 (2012-09-19) is incompatible with it; see
+   <http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html>.
+   Perhaps Apple will fix this some day.  */
+#if ((__GNUC__ \
+      ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \
+      : 199901L <= __STDC_VERSION__) \
+     && !defined __APPLE__)
 # define _GL_INLINE inline
 # define _GL_EXTERN_INLINE extern inline
-#elif 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
+#elif 2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __APPLE__
 # if __GNUC_GNU_INLINE__
    /* __gnu_inline__ suppresses a GCC 4.2 diagnostic.  */
 #  define _GL_INLINE extern inline __attribute__ ((__gnu_inline__))
@@ -32,8 +37,8 @@ AC_DEFUN([gl_EXTERN_INLINE],
 # endif
 # define _GL_EXTERN_INLINE extern
 #else
-# define _GL_INLINE static inline
-# define _GL_EXTERN_INLINE static inline
+# define _GL_INLINE static _GL_UNUSED
+# define _GL_EXTERN_INLINE static _GL_UNUSED
 #endif
 
 #if 4 < __GNUC__ + (6 <= __GNUC_MINOR__)
diff --git a/m4/fcntl-o.m4 b/m4/fcntl-o.m4
index 740e78b..87cc4bd 100644
--- a/m4/fcntl-o.m4
+++ b/m4/fcntl-o.m4
@@ -1,5 +1,5 @@
 # fcntl-o.m4 serial 4
-dnl Copyright (C) 2006, 2009-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/fcntl_h.m4 b/m4/fcntl_h.m4
index cac28ae..3cff1fd 100644
--- a/m4/fcntl_h.m4
+++ b/m4/fcntl_h.m4
@@ -1,6 +1,6 @@
 # serial 15
 # Configure fcntl.h.
-dnl Copyright (C) 2006-2007, 2009-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2006-2007, 2009-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/float_h.m4 b/m4/float_h.m4
index 51c9c7b..397f2d1 100644
--- a/m4/float_h.m4
+++ b/m4/float_h.m4
@@ -1,5 +1,5 @@
 # float_h.m4 serial 9
-dnl Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/flock.m4 b/m4/flock.m4
index 7746883..bbcc4f9 100644
--- a/m4/flock.m4
+++ b/m4/flock.m4
@@ -1,5 +1,5 @@
 # flock.m4 serial 3
-dnl Copyright (C) 2008-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2008-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/floor.m4 b/m4/floor.m4
index a6e7ec8..c176a99 100644
--- a/m4/floor.m4
+++ b/m4/floor.m4
@@ -1,5 +1,5 @@
 # floor.m4 serial 8
-dnl Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/fpieee.m4 b/m4/fpieee.m4
index 82fd778..97941bb 100644
--- a/m4/fpieee.m4
+++ b/m4/fpieee.m4
@@ -1,5 +1,5 @@
 # fpieee.m4 serial 2
-dnl Copyright (C) 2007, 2009-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/frexp.m4 b/m4/frexp.m4
index fb8db70..3909792 100644
--- a/m4/frexp.m4
+++ b/m4/frexp.m4
@@ -1,5 +1,5 @@
 # frexp.m4 serial 14
-dnl Copyright (C) 2007-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2007-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/fstat.m4 b/m4/fstat.m4
index 3ab3297..b2cf2ad 100644
--- a/m4/fstat.m4
+++ b/m4/fstat.m4
@@ -1,5 +1,5 @@
-# fstat.m4 serial 3
-dnl Copyright (C) 2011-2012 Free Software Foundation, Inc.
+# fstat.m4 serial 4
+dnl Copyright (C) 2011-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -33,7 +33,4 @@ AC_DEFUN([gl_FUNC_FSTAT],
 ])
 
 # Prerequisites of lib/fstat.c.
-AC_DEFUN([gl_PREREQ_FSTAT],
-[
-  AC_REQUIRE([AC_C_INLINE])
-])
+AC_DEFUN([gl_PREREQ_FSTAT], [:])
diff --git a/m4/func.m4 b/m4/func.m4
index 13c204d..5548d5e 100644
--- a/m4/func.m4
+++ b/m4/func.m4
@@ -1,5 +1,5 @@
 # func.m4 serial 2
-dnl Copyright (C) 2008-2012 Free Software Foundation, Inc.
+dnl Copyright (C) 2008-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
diff --git a/m4/getaddrinfo.m4 b/m4/getaddrinfo.m4
index 9cd3e67..1d631f8 100644
--- a/m4/getaddrinfo.m4
+++ b/m4/getaddrinfo.m4
@@ -1,5 +1,5 @@
-# getaddrinfo.m4 serial 29
-dnl Copyright (C) 2004-2012 Free Software Foundation, Inc.
+# getaddrinfo.m4 serial 30
+dnl Copyright (C) 2004-2013 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -134,7 +134,6 @@ AC_DEFUN([gl_PREREQ_GETADDRINFO], [
   AC_REQUIRE([AC_C_RESTRICT])
   AC_REQUIRE([gl_SOCKET_FAMILIES])
   AC_REQUIRE([gl_HEADER_SYS_SOCKET])
-  AC_REQUIRE([AC_C_INLINE])
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
   dnl Including sys/socket.h is wrong for Windows, but Windows does not
diff --git a/m4/getlogin.m4 b/m4/getlogin.m4
new file mode 100644
index 0000000..9b3f3cd
--- /dev/null
+++ b/m4/getlogin.m4
@@ -0,0 +1,14 @@
+# getlogin.m4 serial 3
+dnl Copyright (C) 2010-2013 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_GETLOGIN],
+[
+  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
+  AC_CHECK_FUNCS_ONCE([getlogin])
+  if test $ac_cv_func_getlogin = no; then
+    HAVE_GETLOGIN=0
+  fi
+])
diff --git a/m4/glibc21.m4 b/m4/glibc21.m4
index c938fb1..613fb2a 100644
--- a/m4/glibc21.m4
+++ b/m4/glibc21.m4
@@ -1,5 +1,5 @@
 # glibc21.m4 serial 5
-dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2012 Free Software Foundation,
+dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2013 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
index 50102b2..81e4646 100644
--- a/m4/gnulib-cache.m4
+++ b/m4/gnulib-cache.m4
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2012 Free Software Foundation, Inc.
+# Copyright (C) 2002-2013 Free Software Foundation, Inc.
 #
 # 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,7 +27,7 @@
 
 
 # Specification in the form of a command-line invocation:
-#   gnulib-tool --import --dir=. --local-dir=gnulib-local --lib=libgnu 
--source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests 
--aux-dir=build-aux --lgpl=3 --no-conditional-dependencies --libtool 
--macro-prefix=gl --no-vc-files accept alignof alloca-opt announce-gen 
autobuild bind byteswap canonicalize-lgpl ceil clock-time close con