summaryrefslogtreecommitdiff
path: root/lisp/url/url-parse.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/url/url-parse.el')
-rw-r--r--lisp/url/url-parse.el74
1 files changed, 16 insertions, 58 deletions
diff --git a/lisp/url/url-parse.el b/lisp/url/url-parse.el
index d45a028cc03..f47ff9a37c3 100644
--- a/lisp/url/url-parse.el
+++ b/lisp/url/url-parse.el
@@ -27,64 +27,24 @@
;;; Code:
(require 'url-vars)
+(eval-when-compile (require 'cl))
(autoload 'url-scheme-get-property "url-methods")
-(defun url-type (urlobj)
- (aref urlobj 0))
+(defstruct (url
+ (:constructor nil)
+ (:constructor url-parse-make-urlobj
+ (&optional type user password host portspec filename
+ target attributes fullness))
+ (:copier nil))
+ type user password host portspec filename target attributes fullness)
-(defun url-user (urlobj)
- (aref urlobj 1))
-
-(defun url-password (urlobj)
- (aref urlobj 2))
-
-(defun url-host (urlobj)
- (aref urlobj 3))
-
-(defun url-port (urlobj)
- (or (aref urlobj 4)
+(defsubst url-port (urlobj)
+ (or (url-portspec urlobj)
(if (url-fullness urlobj)
- (url-scheme-get-property (url-type urlobj) 'default-port))))
-
-(defun url-filename (urlobj)
- (aref urlobj 5))
-
-(defun url-target (urlobj)
- (aref urlobj 6))
-
-(defun url-attributes (urlobj)
- (aref urlobj 7))
-
-(defun url-fullness (urlobj)
- (aref urlobj 8))
-
-(defun url-set-type (urlobj type)
- (aset urlobj 0 type))
-
-(defun url-set-user (urlobj user)
- (aset urlobj 1 user))
-
-(defun url-set-password (urlobj pass)
- (aset urlobj 2 pass))
-
-(defun url-set-host (urlobj host)
- (aset urlobj 3 host))
-
-(defun url-set-port (urlobj port)
- (aset urlobj 4 port))
-
-(defun url-set-filename (urlobj file)
- (aset urlobj 5 file))
-
-(defun url-set-target (urlobj targ)
- (aset urlobj 6 targ))
-
-(defun url-set-attributes (urlobj targ)
- (aset urlobj 7 targ))
+ (url-scheme-get-property (url-type urlobj) 'default-port))))
-(defun url-set-full (urlobj val)
- (aset urlobj 8 val))
+(defsetf url-port (urlobj) (port) `(setf (url-portspec ,urlobj) ,port))
;;;###autoload
(defun url-recreate-url (urlobj)
@@ -123,17 +83,14 @@ Format is:
;; See RFC 3986.
(cond
((null url)
- (make-vector 9 nil))
+ (url-parse-make-urlobj))
((or (not (string-match url-nonrelative-link url))
(= ?/ (string-to-char url)))
;; This isn't correct, as a relative URL can be a fragment link
;; (e.g. "#foo") and many other things (see section 4.2).
;; However, let's not fix something that isn't broken, especially
;; when close to a release.
- (let ((retval (make-vector 9 nil)))
- (url-set-filename retval url)
- (url-set-full retval nil)
- retval))
+ (url-parse-make-urlobj nil nil nil nil nil url))
(t
(with-temp-buffer
(set-syntax-table url-parse-syntax-table)
@@ -214,7 +171,8 @@ Format is:
(setq file (buffer-substring save-pos (point)))
(if (and host (string-match "%[0-9][0-9]" host))
(setq host (url-unhex-string host)))
- (vector prot user pass host port file refs attr full))))))
+ (url-parse-make-urlobj
+ prot user pass host port file refs attr full))))))
(provide 'url-parse)