From 7785079c7eabe07bc835f8ca7e42fb5594ed25d2 Mon Sep 17 00:00:00 2001
From: Francois-Rene Rideau <tunes@google.com>
Date: Fri, 11 Jan 2013 12:46:58 -0500
Subject: [PATCH] 2.26.77: Fix package mix. Export driver. Move encoding
 support to stream.

---
 Makefile         |  4 +--
 asdf-driver.asd  |  5 ++--
 asdf.asd         |  2 +-
 component.lisp   | 53 ++--------------------------------------
 driver.lisp      | 10 ++++++++
 find-system.lisp |  4 +--
 header.lisp      |  2 +-
 package.lisp     | 19 ++++++---------
 run-program.lisp |  5 ----
 stream.lisp      | 63 +++++++++++++++++++++++++++++++++++++++++++++---
 upgrade.lisp     |  2 +-
 11 files changed, 90 insertions(+), 79 deletions(-)
 create mode 100644 driver.lisp

diff --git a/Makefile b/Makefile
index 34d2417c..50017cc9 100644
--- a/Makefile
+++ b/Makefile
@@ -51,8 +51,8 @@ archive-copy: archive build/asdf.lisp
 	${MAKE} push
 	git checkout master
 
-driver_lisp := header.lisp package.lisp compatibility.lisp utility.lisp upgrade.lisp pathname.lisp stream.lisp os.lisp image.lisp run-program.lisp lisp-build.lisp
-asdf_lisp := component.lisp system.lisp find-system.lisp find-component.lisp operation.lisp action.lisp lisp-action.lisp plan.lisp operate.lisp configuration.lisp output-translations.lisp source-registry.lisp backward-internals.lisp defsystem.lisp bundle.lisp concatenate-source.lisp backward-interface.lisp interface.lisp footer.lisp
+driver_lisp := header.lisp package.lisp compatibility.lisp utility.lisp pathname.lisp stream.lisp os.lisp image.lisp run-program.lisp lisp-build.lisp driver.lisp
+asdf_lisp := upgrade.lisp component.lisp system.lisp find-system.lisp find-component.lisp operation.lisp action.lisp lisp-action.lisp plan.lisp operate.lisp configuration.lisp output-translations.lisp source-registry.lisp backward-internals.lisp defsystem.lisp bundle.lisp concatenate-source.lisp backward-interface.lisp interface.lisp footer.lisp
 
 build/asdf.lisp: $(wildcard *.lisp)
 	mkdir -p build
diff --git a/asdf-driver.asd b/asdf-driver.asd
index 6b240de4..5652ee2d 100644
--- a/asdf-driver.asd
+++ b/asdf-driver.asd
@@ -11,8 +11,9 @@ that you can't portably construct a complete program without using them."
    (:file "compatibility" :depends-on ("package"))
    (:file "utility" :depends-on ("compatibility"))
    (:file "pathname" :depends-on ("utility"))
-   (:file "stream" :depends-on ("utility"))
+   (:file "stream" :depends-on ("pathname"))
    (:file "os" :depends-on ("pathname" "stream"))
    (:file "image" :depends-on ("os"))
    (:file "run-program" :depends-on ("os"))
-   (:file "lisp-build" :depends-on ("image"))))
+   (:file "lisp-build" :depends-on ("image"))
+   (:file "driver" :depends-on ("lisp-build" "run-program"))))
diff --git a/asdf.asd b/asdf.asd
index 9cfbb43c..b3ee9ef1 100644
--- a/asdf.asd
+++ b/asdf.asd
@@ -15,7 +15,7 @@
   :licence "MIT"
   :description "Another System Definition Facility"
   :long-description "ASDF builds Common Lisp software organized into defined systems."
-  :version "2.26.76" ;; to be automatically updated by bin/bump-revision
+  :version "2.26.77" ;; to be automatically updated by bin/bump-revision
   :depends-on ()
   :components ((:module "build" :components ((:file "asdf")))))
 
diff --git a/component.lisp b/component.lisp
index eb7b7bbc..9aa70551 100644
--- a/component.lisp
+++ b/component.lisp
@@ -3,7 +3,7 @@
 
 (asdf/package:define-package :asdf/component
   (:recycle :asdf/component :asdf)
-  (:use :common-lisp :asdf/utility :asdf/pathname :asdf/upgrade)
+  (:use :common-lisp :asdf/utility :asdf/pathname :asdf/stream :asdf/upgrade)
   (:intern #:name #:version #:description #:long-description
            #:sibling-dependencies #:if-feature #:in-order-to #:inline-methods
            #:relative-pathname #:absolute-pathname #:operation-times #:around-compile
@@ -21,10 +21,7 @@
    #:component-inline-methods ;; backward-compatibility only. DO NOT USE!
    #:component-operation-times ;; For internal use only.
    ;; portable ASDF encoding and implementation-specific external-format
-   #:component-external-format #:component-encoding
-   #:detect-encoding #:*encoding-detection-hook* #:always-default-encoding
-   #:encoding-external-format #:*encoding-external-format-hook* #:default-encoding-external-format
-   #:*default-encoding* #:*utf-8-external-format*))
+   #:component-external-format #:component-encoding))
 (in-package :asdf/component)
 
 (defgeneric* component-name (component)
@@ -162,57 +159,11 @@ another pathname in a degenerate way."))
 
 ;;;; Encodings
 
-(defvar *default-encoding* :default
-  "Default encoding for source files.
-The default value :default preserves the legacy behavior.
-A future default might be :utf-8 or :autodetect
-reading emacs-style -*- coding: utf-8 -*- specifications,
-and falling back to utf-8 or latin1 if nothing is specified.")
-
-(defparameter *utf-8-external-format*
-  #+(and asdf-unicode (not clisp)) :utf-8
-  #+(and asdf-unicode clisp) charset:utf-8
-  #-asdf-unicode :default
-  "Default :external-format argument to pass to CL:OPEN and also
-CL:LOAD or CL:COMPILE-FILE to best process a UTF-8 encoded file.
-On modern implementations, this will decode UTF-8 code points as CL characters.
-On legacy implementations, it may fall back on some 8-bit encoding,
-with non-ASCII code points being read as several CL characters;
-hopefully, if done consistently, that won't affect program behavior too much.")
-
-(defun* always-default-encoding (pathname)
-  (declare (ignore pathname))
-  *default-encoding*)
-
-(defvar *encoding-detection-hook* #'always-default-encoding
-  "Hook for an extension to define a function to automatically detect a file's encoding")
-
-(defun* detect-encoding (pathname)
-  (if (and pathname (not (directory-pathname-p pathname)) (probe-file pathname))
-      (funcall *encoding-detection-hook* pathname)
-      *default-encoding*))
-
 (defmethod component-encoding ((c component))
   (or (loop :for x = c :then (component-parent x)
         :while x :thereis (%component-encoding x))
       (detect-encoding (component-pathname c))))
 
-(defun* default-encoding-external-format (encoding)
-  (case encoding
-    (:default :default) ;; for backward-compatibility only. Explicit usage discouraged.
-    (:utf-8 *utf-8-external-format*)
-    (otherwise
-     (cerror "Continue using :external-format :default" (compatfmt "~@<Your ASDF component is using encoding ~S but it isn't recognized. Your system should :defsystem-depends-on (:asdf-encodings).~:>") encoding)
-     :default)))
-
-(defvar *encoding-external-format-hook*
-  #'default-encoding-external-format
-  "Hook for an extension to define a mapping between non-default encodings
-and implementation-defined external-format's")
-
-(defun* encoding-external-format (encoding)
-  (funcall *encoding-external-format-hook* encoding))
-
 (defmethod component-external-format ((c component))
   (encoding-external-format (component-encoding c)))
 
diff --git a/driver.lisp b/driver.lisp
new file mode 100644
index 00000000..5d525645
--- /dev/null
+++ b/driver.lisp
@@ -0,0 +1,10 @@
+;;;; ---------------------------------------------------------------------------
+;;;; Re-export all the functionality in asdf/driver
+
+(asdf/package:define-package :asdf/driver
+  (:use
+   :common-lisp :asdf/package :asdf/compatibility :asdf/utility
+   :asdf/pathname :asdf/stream :asdf/os :asdf/image :asdf/run-program :asdf/lisp-build)
+  (:reexport
+   :asdf/package :asdf/compatibility :asdf/utility
+   :asdf/pathname :asdf/stream :asdf/os :asdf/image :asdf/run-program :asdf/lisp-build))
diff --git a/find-system.lisp b/find-system.lisp
index 11ac90d0..eddc75a3 100644
--- a/find-system.lisp
+++ b/find-system.lisp
@@ -3,8 +3,8 @@
 
 (asdf/package:define-package :asdf/find-system
   (:recycle :asdf/find-system :asdf)
-  (:use :common-lisp :asdf/compatibility :asdf/utility :asdf/upgrade :asdf/pathname :asdf/os
-   :asdf/component :asdf/system)
+  (:use :common-lisp :asdf/compatibility :asdf/utility :asdf/pathname :asdf/stream :asdf/os
+        :asdf/upgrade :asdf/component :asdf/system)
   (:export
    #:coerce-name #:find-system #:locate-system #:load-sysdef #:with-system-definitions
    #:system-registered-p #:register-system #:registered-systems #:clear-system #:map-systems
diff --git a/header.lisp b/header.lisp
index 3b35dd39..9d21fd87 100644
--- a/header.lisp
+++ b/header.lisp
@@ -1,5 +1,5 @@
 ;; -*- mode: Common-Lisp; Base: 10 ; Syntax: ANSI-Common-Lisp ; coding: utf-8 -*-
-;;; This is ASDF 2.26.76: Another System Definition Facility.
+;;; This is ASDF 2.26.77: Another System Definition Facility.
 ;;;
 ;;; Feedback, bug reports, and patches are all welcome:
 ;;; please mail to <asdf-devel@common-lisp.net>.
diff --git a/package.lisp b/package.lisp
index e3c0f244..690846f7 100644
--- a/package.lisp
+++ b/package.lisp
@@ -274,7 +274,7 @@ or when loading the package is optional."
                     (when intern (intern* name package)))
                    (t (rehome-symbol recycled package))))))
            (ensure-export (name p)
-             (multiple-value-bind (symbol status) (find-symbol name p)
+             (multiple-value-bind (symbol status) (find-symbol* name p)
                (assert status)
                (unless (eq status :external)
                  (ensure-exported name symbol p))))
@@ -305,12 +305,10 @@ or when loading the package is optional."
         (loop :for p :in (set-difference (package-use-list package) (append mix use))
               :do (unuse-package p package))
         (dolist (name unintern) (unintern* name package nil))
-        (loop :for sym :in export :for name = (string sym) :do
-          (setf (gethash name exported) t))
+        (dolist (sym export) (setf (gethash (string sym) exported) t))
         (loop :for p :in reexport :do
           (do-external-symbols (sym p)
-            (let ((name (string sym)))
-              (export (find-symbol* name package) package) (setf (gethash name exported) t))))
+            (setf (gethash (string sym) exported) t)))
         (do-external-symbols (sym package)
           (unless (gethash (symbol-name sym) exported) (unexport sym package)))
         (loop :for s :in shadow :for name = (string s) :do
@@ -329,17 +327,16 @@ or when loading the package is optional."
           (do-external-symbols (sym p) (ensure-mix sym p)))
         (loop :for (p . syms) :in import-from :do
           (dolist (sym syms) (ensure-import sym p)))
-        (loop :for p :in use :for sp = (string p) :for pp = (find-package* sp) :do
-          (do-external-symbols (sym pp) (ensure-inherited sym sp))
+        (loop :for p :in (append use mix) :for pp = (find-package* p) :do
+          (do-external-symbols (sym pp) (ensure-inherited sym pp))
           (use-package pp package))
         (loop :for name :being :the :hash-keys :of exported :do
-          (ensure-symbol name t))
-       (dolist (name intern)
+          (ensure-symbol (string name) t)
+          (ensure-export name package))
+        (dolist (name intern)
           (ensure-symbol (string name) t))
         (do-symbols (sym package)
           (ensure-symbol (symbol-name sym)))
-        (loop :for name :being :the :hash-keys :of exported :do
-          (ensure-export name package))
         package))))
 
 (eval-when (:load-toplevel :compile-toplevel :execute)
diff --git a/run-program.lisp b/run-program.lisp
index d24ad9e4..85e5e277 100644
--- a/run-program.lisp
+++ b/run-program.lisp
@@ -37,11 +37,6 @@ as either a recognizing function or a sequence of characters."
      (t (error "requires-escaping-p: no good-char criterion")))
    token))
 
-(defun output-string (string &optional stream)
-  (if stream
-      (with-output (stream) (princ string stream))
-      string))
-
 (defun escape-token (token &key stream quote good-chars bad-chars escaper)
   "Call the ESCAPER function on TOKEN string if it needs escaping as per
 REQUIRES-ESCAPING-P using GOOD-CHARS and BAD-CHARS, otherwise output TOKEN,
diff --git a/stream.lisp b/stream.lisp
index 9fabbe67..e705d405 100644
--- a/stream.lisp
+++ b/stream.lisp
@@ -3,18 +3,21 @@
 
 (asdf/package:define-package :asdf/stream
   (:recycle :asdf/stream)
-  (:use :cl :asdf/package :asdf/compatibility :asdf/utility)
+  (:use :cl :asdf/package :asdf/compatibility :asdf/utility :asdf/pathname)
   (:export
    #:*default-stream-element-type* #:*stderr*
    #:finish-outputs #:format!
-   #:with-output #:with-input #:call-with-input-file
+   #:with-output #:output-string #:with-input #:call-with-input-file
    #:with-safe-io-syntax #:read-function
    #:read-file-forms #:read-first-file-form
    #:copy-stream-to-stream #:concatenate-files
    #:copy-stream-to-stream-line-by-line
    #:slurp-stream-string #:slurp-stream-lines
    #:slurp-stream-forms #:slurp-file-string
-   #:slurp-file-lines #:slurp-file-forms))
+   #:slurp-file-lines #:slurp-file-forms
+   #:detect-encoding #:*encoding-detection-hook* #:always-default-encoding
+   #:encoding-external-format #:*encoding-external-format-hook* #:default-encoding-external-format
+   #:*default-encoding* #:*utf-8-external-format*))
 (in-package :asdf/stream)
 
 (defvar *default-stream-element-type* (or #+(or abcl cmu cormanlisp scl xcl) 'character :default)
@@ -77,6 +80,11 @@ Otherwise, signal an error.")
 as per FORMAT, and evaluate BODY within the scope of this binding."
   `(call-with-output ,value #'(lambda (,x) ,@body)))
 
+(defun output-string (string &optional stream)
+  (if stream
+      (with-output (stream) (princ string stream))
+      string))
+
 
 ;;; Input helpers
 
@@ -188,3 +196,52 @@ reading contents line by line."
   "Open FILE with option KEYS, read its contents as a list of forms"
   (apply 'call-with-input-file file 'slurp-stream-forms keys))
 
+
+;;; Encodings
+
+(defvar *default-encoding* :default
+  "Default encoding for source files.
+The default value :default preserves the legacy behavior.
+A future default might be :utf-8 or :autodetect
+reading emacs-style -*- coding: utf-8 -*- specifications,
+and falling back to utf-8 or latin1 if nothing is specified.")
+
+(defparameter *utf-8-external-format*
+  #+(and asdf-unicode (not clisp)) :utf-8
+  #+(and asdf-unicode clisp) charset:utf-8
+  #-asdf-unicode :default
+  "Default :external-format argument to pass to CL:OPEN and also
+CL:LOAD or CL:COMPILE-FILE to best process a UTF-8 encoded file.
+On modern implementations, this will decode UTF-8 code points as CL characters.
+On legacy implementations, it may fall back on some 8-bit encoding,
+with non-ASCII code points being read as several CL characters;
+hopefully, if done consistently, that won't affect program behavior too much.")
+
+(defun* always-default-encoding (pathname)
+  (declare (ignore pathname))
+  *default-encoding*)
+
+(defvar *encoding-detection-hook* #'always-default-encoding
+  "Hook for an extension to define a function to automatically detect a file's encoding")
+
+(defun* detect-encoding (pathname)
+  (if (and pathname (not (directory-pathname-p pathname)) (probe-file pathname))
+      (funcall *encoding-detection-hook* pathname)
+      *default-encoding*))
+
+(defun* default-encoding-external-format (encoding)
+  (case encoding
+    (:default :default) ;; for backward-compatibility only. Explicit usage discouraged.
+    (:utf-8 *utf-8-external-format*)
+    (otherwise
+     (cerror "Continue using :external-format :default" (compatfmt "~@<Your ASDF component is using encoding ~S but it isn't recognized. Your system should :defsystem-depends-on (:asdf-encodings).~:>") encoding)
+     :default)))
+
+(defvar *encoding-external-format-hook*
+  #'default-encoding-external-format
+  "Hook for an extension to define a mapping between non-default encodings
+and implementation-defined external-format's")
+
+(defun* encoding-external-format (encoding)
+  (funcall *encoding-external-format-hook* encoding))
+
diff --git a/upgrade.lisp b/upgrade.lisp
index 3b1d3add..efdaf855 100644
--- a/upgrade.lisp
+++ b/upgrade.lisp
@@ -31,7 +31,7 @@
          ;; "2.345.6" would be a development version in the official upstream
          ;; "2.345.0.7" would be your seventh local modification of official release 2.345
          ;; "2.345.6.7" would be your seventh local modification of development version 2.345.6
-         (asdf-version "2.26.76")
+         (asdf-version "2.26.77")
          (existing-asdf (find-class (find-symbol* :component :asdf nil) nil))
          (existing-version *asdf-version*)
          (already-there (equal asdf-version existing-version)))
-- 
GitLab