1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-15 16:20:17 +02:00

Merge remote-tracking branch 'origin/stable-2.0'

Moved scm_i_struct_hash from struct.c to hash.c and made it static.

The port's alist is now a field of 'scm_t_port'.

Conflicts:
	libguile/arrays.c
	libguile/hash.c
	libguile/ports.c
	libguile/print.h
	libguile/read.c
This commit is contained in:
Mark H Weaver 2012-10-30 23:46:31 -04:00
commit fa980bcc0f
53 changed files with 1677 additions and 531 deletions

View file

@ -1,6 +1,6 @@
;;; Web client
;; Copyright (C) 2011 Free Software Foundation, Inc.
;; Copyright (C) 2011, 2012 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
@ -42,19 +42,37 @@
http-get))
(define (open-socket-for-uri uri)
(let* ((ai (car (getaddrinfo (uri-host uri)
(cond
((uri-port uri) => number->string)
(else (symbol->string (uri-scheme uri)))))))
(s (socket (addrinfo:fam ai) (addrinfo:socktype ai)
(addrinfo:protocol ai))))
(set-port-encoding! s "ISO-8859-1")
(connect s (addrinfo:addr ai))
;; Buffer input and output on this port.
(setvbuf s _IOFBF)
;; Enlarge the receive buffer.
(setsockopt s SOL_SOCKET SO_RCVBUF (* 12 1024))
s))
"Return an open input/output port for a connection to URI."
(define addresses
(let ((port (uri-port uri)))
(getaddrinfo (uri-host uri)
(cond (port => number->string)
(else (symbol->string (uri-scheme uri))))
(if port
AI_NUMERICSERV
0))))
(let loop ((addresses addresses))
(let* ((ai (car addresses))
(s (socket (addrinfo:fam ai) (addrinfo:socktype ai)
(addrinfo:protocol ai))))
(set-port-encoding! s "ISO-8859-1")
(catch 'system-error
(lambda ()
(connect s (addrinfo:addr ai))
;; Buffer input and output on this port.
(setvbuf s _IOFBF)
;; Enlarge the receive buffer.
(setsockopt s SOL_SOCKET SO_RCVBUF (* 12 1024))
s)
(lambda args
;; Connection failed, so try one of the other addresses.
(close s)
(if (null? addresses)
(apply throw args)
(loop (cdr addresses))))))))
(define (decode-string bv encoding)
(if (string-ci=? encoding "utf-8")

View file

@ -364,7 +364,9 @@ Percent-encoding first writes out the given character to a bytevector
within the given @var{encoding}, then encodes each byte as
@code{%@var{HH}}, where @var{HH} is the hexadecimal representation of
the byte."
(if (string-index str unescaped-chars)
(define (needs-escaped? ch)
(not (char-set-contains? unescaped-chars ch)))
(if (string-index str needs-escaped?)
(call-with-output-string*
(lambda (port)
(string-for-each
@ -377,6 +379,8 @@ the byte."
(if (< i len)
(let ((byte (bytevector-u8-ref bv i)))
(display #\% port)
(when (< byte 16)
(display #\0 port))
(display (number->string byte 16) port)
(lp (1+ i))))))))
str)))