Add autoloading library aliasing support (supersedes PR #2824)
diff --git a/application/config/autoload.php b/application/config/autoload.php
index 5a20c94..43d5315 100644
--- a/application/config/autoload.php
+++ b/application/config/autoload.php
@@ -77,6 +77,11 @@
 | Prototype:
 |
 |	$autoload['libraries'] = array('database', 'email', 'xmlrpc');
+|
+| You can also supply an alternative library name to be assigned
+| in the controller:
+|
+|	$autoload['libraries'] = array('user_agent' => 'ua');
 */
 
 $autoload['libraries'] = array();
diff --git a/system/core/Loader.php b/system/core/Loader.php
index 7817258..8c8d5a3 100644
--- a/system/core/Loader.php
+++ b/system/core/Loader.php
@@ -184,9 +184,16 @@
 		}
 		elseif (is_array($library))
 		{
-			foreach ($library as $class)
+			foreach ($library as $key => $value)
 			{
-				$this->library($class, $params);
+				if (is_int($key))
+				{
+					$this->library($value, $params);
+				}
+				else
+				{
+					$this->library($key, $params, $value);
+				}
 			}
 
 			return $this;
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 8618e5e..539c613 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -408,7 +408,7 @@
       -  Added autoloading of drivers with ``$autoload['drivers']``.
       -  ``$config['rewrite_short_tags']`` now has no effect when using PHP 5.4 as ``<?=`` will always be available.
       -  Changed method ``config()`` to return whatever ``CI_Config::load()`` returns instead of always being void.
-      -  Added support for model aliasing on autoload.
+      -  Added support for library and model aliasing on autoload.
       -  Changed method ``is_loaded()`` to ask for the (case sensitive) library name instead of its instance name.
       -  Removed ``$_base_classes`` property and unified all class data in ``$_ci_classes`` instead.
       -  Added method ``clear_vars()`` to allow clearing the cached variables for views.