From 4942a7b77917f9a163453ecdd040993965672cc0 Mon Sep 17 00:00:00 2001
From: Aaron Brashears <aaronb@lindenlab.com>
Date: Thu, 4 Oct 2007 16:31:48 +0000
Subject: [PATCH] Result of svn merge -r70873:71086
 svn+ssh://svn/svn/linden/branches/enable-exceptions into release.

---
 .../linux_crash_logger/linux_crash_logger.cpp |  3 -
 indra/llaudio/llaudiodecodemgr.cpp            |  5 --
 indra/llcharacter/llanimationstates.cpp       |  2 -
 indra/llcharacter/llbvhloader.cpp             |  8 +-
 indra/llcharacter/llbvhloader.h               |  5 --
 indra/llcharacter/lljointsolverrp3.cpp        |  2 -
 indra/llcommon/ctype_workaround.h             |  2 +-
 indra/llcommon/linden_common.h                | 34 +++++----
 indra/llcommon/llassettype.cpp                |  2 -
 indra/llcommon/llcriticaldamp.cpp             |  1 -
 indra/llcommon/lldlinked.h                    |  2 -
 indra/llcommon/llerror.cpp                    | 27 +++----
 indra/llcommon/llfasttimer.h                  |  2 -
 indra/llcommon/llfile.h                       |  7 +-
 indra/llcommon/llformat.cpp                   |  2 +-
 indra/llcommon/llformat.h                     |  2 -
 indra/llcommon/llmap.h                        |  4 -
 indra/llcommon/llprocessor.cpp                |  4 +-
 indra/llcommon/llsd.cpp                       |  3 -
 indra/llcommon/llstl.h                        |  6 --
 indra/llcommon/llstring.cpp                   | 20 +++++
 indra/llcommon/llstring.h                     | 73 +++----------------
 indra/llcommon/llsys.cpp                      |  2 +
 indra/llcommon/lltimer.cpp                    |  3 -
 indra/llcommon/lltimer.h                      |  5 +-
 indra/llcommon/stdtypes.h                     |  3 -
 indra/llcommon/timing.h                       |  3 +-
 indra/llimage/llimage.cpp                     |  8 +-
 indra/llimage/llimage.h                       |  1 -
 indra/llinventory/llinventory.cpp             |  2 -
 indra/llinventory/lllandmark.cpp              |  3 -
 indra/llinventory/llparcel.h                  |  4 -
 indra/llinventory/llpermissions.h             |  3 -
 indra/llinventory/llsaleinfo.h                |  3 -
 indra/llmath/llmath.h                         |  6 --
 indra/llmath/v2math.h                         |  2 -
 indra/llmessage/llassetstorage.cpp            |  3 -
 indra/llmessage/llcachename.cpp               |  7 --
 indra/llmessage/llcachename.h                 |  3 -
 indra/llmessage/lldatapacker.cpp              |  2 -
 indra/llmessage/lldatapacker.h                |  5 --
 indra/llmessage/llnamevalue.h                 |  4 -
 indra/llmessage/llpartdata.h                  |  2 -
 indra/llmessage/llregionhandle.h              |  2 -
 indra/llmessage/lltransfersourcefile.h        |  2 -
 indra/llmessage/lltransfertargetfile.h        |  2 -
 indra/llmessage/llxfer_file.h                 |  2 -
 indra/llmessage/llxfer_mem.h                  |  2 -
 indra/llmessage/llxfer_vfile.h                |  2 -
 indra/llmessage/mean_collision_data.h         |  2 +-
 indra/llmessage/message.cpp                   |  8 +-
 indra/llmessage/message.h                     |  2 -
 indra/llmessage/net.cpp                       |  1 -
 indra/llui/llview.cpp                         | 16 ++--
 indra/llui/llview.h                           | 22 +++---
 indra/llvfs/lldir.cpp                         |  1 +
 indra/llvfs/lldir_linux.h                     |  1 -
 indra/llvfs/lldir_mac.h                       |  1 -
 indra/llvfs/lldir_solaris.h                   |  1 -
 indra/llvfs/llvfs.cpp                         |  2 -
 indra/llvfs/llvfs.h                           |  2 -
 indra/llwindow/lldxhardware.cpp               |  1 -
 indra/lscript/lscript_alloc.h                 |  3 -
 indra/lscript/lscript_compile/indra.l         |  8 +-
 indra/lscript/lscript_compile/indra.y         |  5 +-
 indra/lscript/lscript_compile/lscript_error.h |  3 -
 .../lscript_compile/lscript_resource.h        |  2 -
 indra/lscript/lscript_compile/lscript_tree.h  |  2 -
 indra/lscript/lscript_execute.h               |  1 -
 indra/lscript/lscript_library.h               |  1 -
 .../lscript/lscript_library/lscript_alloc.cpp |  2 +-
 indra/mac_crash_logger/mac_crash_logger.cpp   |  4 -
 indra/mac_updater/mac_updater.cpp             |  4 -
 indra/newview/llfloaterland.cpp               |  1 -
 indra/newview/llpanelland.cpp                 |  2 -
 indra/newview/llurl.cpp                       |  1 -
 indra/newview/llviewermessage.cpp             |  2 -
 indra/newview/llviewerwindow.cpp              |  5 --
 indra/test/llblowfish_tut.cpp                 |  2 -
 indra/test/llbuffer_tut.cpp                   |  1 +
 indra/test/llhttpdate_tut.cpp                 |  3 -
 indra/test/llhttpnode_tut.cpp                 |  3 +-
 indra/test/lliohttpserver_tut.cpp             |  3 +-
 indra/test/llmessageconfig_tut.cpp            |  4 +-
 indra/test/llmessagetemplateparser_tut.cpp    |  3 +-
 indra/test/llsaleinfo_tut.cpp                 |  2 +-
 indra/test/llsd_new_tut.cpp                   |  1 -
 indra/test/llsdmessagebuilder_tut.cpp         |  3 +-
 indra/test/llservicebuilder_tut.cpp           |  3 +-
 indra/test/llstreamtools_tut.cpp              |  3 +-
 indra/test/llxorcipher_tut.cpp                |  2 +-
 indra/win_crash_logger/win_crash_logger.cpp   |  3 -
 indra/win_updater/updater.cpp                 |  7 +-
 93 files changed, 121 insertions(+), 330 deletions(-)

diff --git a/indra/linux_crash_logger/linux_crash_logger.cpp b/indra/linux_crash_logger/linux_crash_logger.cpp
index 54c257b77b0..a829944118a 100644
--- a/indra/linux_crash_logger/linux_crash_logger.cpp
+++ b/indra/linux_crash_logger/linux_crash_logger.cpp
@@ -8,9 +8,6 @@
 
 #include "linden_common.h"
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
diff --git a/indra/llaudio/llaudiodecodemgr.cpp b/indra/llaudio/llaudiodecodemgr.cpp
index 1b4c952e8e3..f2dd75b7ee0 100644
--- a/indra/llaudio/llaudiodecodemgr.cpp
+++ b/indra/llaudio/llaudiodecodemgr.cpp
@@ -7,11 +7,6 @@
 
 #include "linden_common.h"
 
-#include <vector>
-#include <iterator>
-#include <algorithm>
-#include <stdio.h>
-
 #include "llaudiodecodemgr.h"
 
 #include "vorbisdecode.h"
diff --git a/indra/llcharacter/llanimationstates.cpp b/indra/llcharacter/llanimationstates.cpp
index 58ba252e04a..9e21e934c41 100644
--- a/indra/llcharacter/llanimationstates.cpp
+++ b/indra/llcharacter/llanimationstates.cpp
@@ -12,8 +12,6 @@
 
 #include "linden_common.h"
 
-#include <string.h>
-
 #include "llanimationstates.h"
 #include "llstring.h"
 
diff --git a/indra/llcharacter/llbvhloader.cpp b/indra/llcharacter/llbvhloader.cpp
index 3be8e121c67..b1eb05f117c 100644
--- a/indra/llcharacter/llbvhloader.cpp
+++ b/indra/llcharacter/llbvhloader.cpp
@@ -9,6 +9,9 @@
 #include "linden_common.h"
 
 #include "llbvhloader.h"
+
+#include <boost/tokenizer.hpp>
+
 #include "lldatapacker.h"
 #include "lldir.h"
 #include "llkeyframemotion.h"
@@ -16,11 +19,6 @@
 #include "llstl.h"
 #include "llapr.h"
 
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include <llquaternion.h>
-#include <boost/tokenizer.hpp>
 
 using namespace std;
 
diff --git a/indra/llcharacter/llbvhloader.h b/indra/llcharacter/llbvhloader.h
index 7e00e1d5f4e..8f6de27be1a 100644
--- a/indra/llcharacter/llbvhloader.h
+++ b/indra/llcharacter/llbvhloader.h
@@ -9,11 +9,6 @@
 #ifndef LL_LLBVHLOADER_H
 #define LL_LLBVHLOADER_H
 
-#include <string>
-#include <vector>
-#include <map>
-#include <stdtypes.h>
-#include <stdio.h>
 #include "v3math.h"
 #include "m3math.h"
 #include "llmath.h"
diff --git a/indra/llcharacter/lljointsolverrp3.cpp b/indra/llcharacter/lljointsolverrp3.cpp
index 60b836734ac..351b7676221 100644
--- a/indra/llcharacter/lljointsolverrp3.cpp
+++ b/indra/llcharacter/lljointsolverrp3.cpp
@@ -13,8 +13,6 @@
 
 #include "lljointsolverrp3.h"
 
-#include <math.h>
-
 #include "llmath.h"
 
 #define F_EPSILON 0.00001f
diff --git a/indra/llcommon/ctype_workaround.h b/indra/llcommon/ctype_workaround.h
index 8c52b0290c4..5b095c8c194 100644
--- a/indra/llcommon/ctype_workaround.h
+++ b/indra/llcommon/ctype_workaround.h
@@ -18,7 +18,7 @@
  * -- Leviathan 20060113
 */
 
-#include <ctype.h>
+#include <cctype>
 
 __const unsigned short int *__ctype_b;
 __const __int32_t *__ctype_tolower;
diff --git a/indra/llcommon/linden_common.h b/indra/llcommon/linden_common.h
index 5826bc917d4..73dfc53c613 100644
--- a/indra/llcommon/linden_common.h
+++ b/indra/llcommon/linden_common.h
@@ -11,34 +11,42 @@
 
 #include "llpreprocessor.h"
 
-#include <string.h>
-#include <math.h>
-#include <stdio.h>
-#include <stdlib.h>
+#include <cstring>
+#include <cfloat>
+#include <climits>
+#include <cmath>
+#include <cstdarg>
+#include <cstdio>
+#include <cstdlib>
+#include <ctime>
+#include <iostream>
+#include <fstream>
 
 // Work around stupid Microsoft STL warning
 #ifdef LL_WINDOWS
 #pragma warning (disable : 4702) // warning C4702: unreachable code
 #endif	//	LL_WINDOWS
 
-#include <iostream>
-#include <fstream>
+#include <algorithm>
+#include <list>
+#include <map>
 #include <vector>
 #include <string>
-#include "llfile.h"
 
+#ifdef LL_WINDOWS
+#pragma warning (3 : 4702) // we like level 3, not 4
+#endif	//	LL_WINDOWS
+
+// Linden only libs in alpha-order other than stdtypes.h
 #include "stdtypes.h"
 #include "lldefs.h"
 #include "llerror.h"
 #include "llextendedstatus.h"
+#include "llfasttimer.h"
+#include "llfile.h"
 #include "llformat.h"
 #include "llstring.h"
-#include "lltimer.h"
-#include "llfasttimer.h"
 #include "llsys.h"
-
-#ifdef LL_WINDOWS
-#pragma warning (3 : 4702) // we like level 3, not 4
-#endif	//	LL_WINDOWS
+#include "lltimer.h"
 
 #endif
diff --git a/indra/llcommon/llassettype.cpp b/indra/llcommon/llassettype.cpp
index b5378943ca2..4b37f0d188e 100644
--- a/indra/llcommon/llassettype.cpp
+++ b/indra/llcommon/llassettype.cpp
@@ -10,8 +10,6 @@
 
 #include "llassettype.h"
 
-#include <time.h>
-
 #include "llstring.h"
 #include "lltimer.h"
 
diff --git a/indra/llcommon/llcriticaldamp.cpp b/indra/llcommon/llcriticaldamp.cpp
index ee7dfecdaae..1757f16c995 100644
--- a/indra/llcommon/llcriticaldamp.cpp
+++ b/indra/llcommon/llcriticaldamp.cpp
@@ -7,7 +7,6 @@
  */
 
 #include "linden_common.h"
-#include <math.h>
 
 #include "llcriticaldamp.h"
 
diff --git a/indra/llcommon/lldlinked.h b/indra/llcommon/lldlinked.h
index 54087848d9e..1e5ddfd1a43 100644
--- a/indra/llcommon/lldlinked.h
+++ b/indra/llcommon/lldlinked.h
@@ -8,8 +8,6 @@
 #ifndef LL_LLDLINKED_H
 #define LL_LLDLINKED_H
 
-#include <stdlib.h>
-
 template <class Type> class LLDLinked
 {
 	LLDLinked* mNextp;
diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp
index 90ea72f24cc..98972950b76 100644
--- a/indra/llcommon/llerror.cpp
+++ b/indra/llcommon/llerror.cpp
@@ -12,33 +12,28 @@
 #include "llerror.h"
 #include "llerrorcontrol.h"
 
-#include "llapp.h"
-#include "llapr.h"
-#include "llfile.h"
-#include "llfixedbuffer.h"
-#include "lllivefile.h"
-#include "llsd.h"
-#include "llsdserialize.h"
-#include "llstl.h"
-
-#include <algorithm>
 #include <cctype>
-#include <map>
+#ifdef __GNUC__
+#include <cxxabi.h>
+#endif
 #include <sstream>
 #if !LL_WINDOWS
-#include <stdio.h>
 #include <syslog.h>
 #endif
-#include <time.h>
 #if LL_WINDOWS
 #include <windows.h>
 #endif
 #include <vector>
 
+#include "llapp.h"
+#include "llapr.h"
+#include "llfile.h"
+#include "llfixedbuffer.h"
+#include "lllivefile.h"
+#include "llsd.h"
+#include "llsdserialize.h"
+#include "llstl.h"
 
-#ifdef __GNUC__
-#include <cxxabi.h>
-#endif
 
 namespace {
 #if !LL_WINDOWS
diff --git a/indra/llcommon/llfasttimer.h b/indra/llcommon/llfasttimer.h
index 3e88784d3c0..648c4bab4ea 100644
--- a/indra/llcommon/llfasttimer.h
+++ b/indra/llcommon/llfasttimer.h
@@ -9,8 +9,6 @@
 #ifndef LL_LLFASTTIMER_H
 #define LL_LLFASTTIMER_H
 
-#include "lltimer.h"
-
 #define FAST_TIMER_ON 1
 
 U64 get_cpu_clock_count();
diff --git a/indra/llcommon/llfile.h b/indra/llcommon/llfile.h
index 605918cd29d..77bd20e274c 100644
--- a/indra/llcommon/llfile.h
+++ b/indra/llcommon/llfile.h
@@ -17,12 +17,6 @@
  * Attempts to mostly mirror the POSIX style IO functions.
  */
 
-#include <string>
-#include <stdio.h>
-#include <sys/stat.h>
-#include <fstream>
-#include "stdtypes.h"
-
 typedef FILE	LLFILE;
 
 #ifdef LL_WINDOWS
@@ -36,6 +30,7 @@ typedef FILE	LLFILE;
 // windows version of stat function and stat data structure are called _stat
 typedef struct _stat	llstat;
 #else
+#include <sys/stat.h>
 typedef struct stat		llstat;
 #endif
 
diff --git a/indra/llcommon/llformat.cpp b/indra/llcommon/llformat.cpp
index 0c2a6d3b1e2..9bfdb14446d 100644
--- a/indra/llcommon/llformat.cpp
+++ b/indra/llcommon/llformat.cpp
@@ -11,7 +11,7 @@
 
 #include "llformat.h"
 
-#include <stdarg.h>
+#include <cstdarg>
 
 std::string llformat(const char *fmt, ...)
 {
diff --git a/indra/llcommon/llformat.h b/indra/llcommon/llformat.h
index 7079656b72e..31ee3194d38 100644
--- a/indra/llcommon/llformat.h
+++ b/indra/llcommon/llformat.h
@@ -10,8 +10,6 @@
 #ifndef LL_LLFORMAT_H
 #define LL_LLFORMAT_H
 
-#include <string>
-
 // Use as follows:
 // llinfos << llformat("Test:%d (%.2f %.2f)", idx, x, y) << llendl;
 //
diff --git a/indra/llcommon/llmap.h b/indra/llcommon/llmap.h
index fc958421dae..97af9f5ec93 100644
--- a/indra/llcommon/llmap.h
+++ b/indra/llcommon/llmap.h
@@ -9,10 +9,6 @@
 #ifndef LL_LLMAP_H
 #define LL_LLMAP_H
 
-#include <stdio.h>
-#include <utility>
-#include <map>
-
 // llmap uses the fast stl library code in a manner consistant with LLSkipMap, et. al. 
 
 template<class INDEX_TYPE, class MAPPED_TYPE> class LLMap
diff --git a/indra/llcommon/llprocessor.cpp b/indra/llcommon/llprocessor.cpp
index c8c565a05b9..c676a37a5ed 100644
--- a/indra/llcommon/llprocessor.cpp
+++ b/indra/llcommon/llprocessor.cpp
@@ -28,9 +28,7 @@
 
 #include "processor.h"
 
-#include <stdio.h>
-#include <string.h>
-#include <memory.h>
+#include <memory>
 
 #if LL_WINDOWS
 #	define WIN32_LEAN_AND_MEAN
diff --git a/indra/llcommon/llsd.cpp b/indra/llcommon/llsd.cpp
index 2fb9a0ab9cb..aa522557046 100644
--- a/indra/llcommon/llsd.cpp
+++ b/indra/llcommon/llsd.cpp
@@ -9,9 +9,6 @@
 #include "linden_common.h"
 #include "llsd.h"
 
-#include <sstream>
-#include <math.h>
-
 #include "llerror.h"
 #include "../llmath/llmath.h"
 #include "llformat.h"
diff --git a/indra/llcommon/llstl.h b/indra/llcommon/llstl.h
index 8a32a04fc2f..541f1a9c81b 100644
--- a/indra/llcommon/llstl.h
+++ b/indra/llcommon/llstl.h
@@ -10,15 +10,9 @@
 #define LL_LLSTL_H
 
 #include <functional>
-#include <algorithm>
-#include <map>
-#include <vector>
 #include <set>
 #include <deque>
 
-#include <stdio.h>
-#include <stdarg.h>
-
 // Use to compare the first element only of a pair
 // e.g. typedef std::set<std::pair<int, Data*>, compare_pair<int, Data*> > some_pair_set_t; 
 template <typename T1, typename T2>
diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp
index 0b799b94ae3..2d7c9033412 100644
--- a/indra/llcommon/llstring.cpp
+++ b/indra/llcommon/llstring.cpp
@@ -35,6 +35,26 @@ U8 hex_as_nybble(char hex)
 }
 
 
+bool _read_file_into_string(std::string& str, const char* filename)
+{
+	llifstream ifs(filename, llifstream::binary);
+	if (!ifs.is_open())
+	{
+		llinfos << "Unable to open file" << filename << llendl;
+		return false;
+	}
+
+	std::ostringstream oss;
+
+	oss << ifs.rdbuf();
+	str = oss.str();
+	ifs.close();
+	return true;
+}
+
+
+
+
 // See http://www.unicode.org/Public/BETA/CVTUTF-1-2/ConvertUTF.c
 // for the Unicode implementation - this doesn't match because it was written before finding
 // it.
diff --git a/indra/llcommon/llstring.h b/indra/llcommon/llstring.h
index 3005155b197..b922b2f8e59 100644
--- a/indra/llcommon/llstring.h
+++ b/indra/llcommon/llstring.h
@@ -9,17 +9,6 @@
 #ifndef LL_LLSTRING_H
 #define LL_LLSTRING_H
 
-#include "stdtypes.h"
-#include "llerror.h"
-#include "llfile.h"
-#include <algorithm>
-#include <map>
-#include <stdio.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <math.h>
-#include <stdarg.h> /* for vsnprintf */
 #if LL_LINUX || LL_SOLARIS
 #include <wctype.h>
 #include <wchar.h>
@@ -260,9 +249,6 @@ class LLStringBase : public std::basic_string<T>
 	 */
 	static void _makeASCII(std::basic_string<T>& string);
 
-	static BOOL	read(std::basic_string<T>& string, const char* filename);	 /*Flawfinder: ignore*/
-	static BOOL	write(std::basic_string<T>& string, const char* filename);
-
 	// Conversion to other data types
 	static BOOL	convertToBOOL(const std::basic_string<T>& string, BOOL& value);
 	static BOOL	convertToU8(const std::basic_string<T>& string, U8& value);
@@ -353,6 +339,16 @@ std::string ll_safe_string(const char* in);
  */
 U8 hex_as_nybble(char hex);
 
+/**
+ * @brief read the contents of a file into a string.
+ *
+ * Since this function has no concept of character encoding, most
+ * anything you do with this method ill-advised. Please avoid.
+ * @param str [out] The string which will have.
+ * @param filename The full name of the file to read.
+ * @return Returns true on success. If false, str is unmodified.
+ */
+bool _read_file_into_string(std::string& str, const char* filename);
 
 /**
  * Unicode support
@@ -913,8 +909,6 @@ void LLStringBase<T>::replaceNonstandardASCII( std::basic_string<T>& string, T r
 template<class T> 
 void LLStringBase<T>::replaceTabsWithSpaces( std::basic_string<T>& str, size_type spaces_per_tab )
 {
-	llassert( spaces_per_tab >= 0 );
-
 	const T TAB = '\t';
 	const T SPACE = ' ';
 
@@ -1017,11 +1011,10 @@ void LLStringBase<T>::copy( T* dst, const T* src, size_type dst_size )
 template<class T> 
 void LLStringBase<T>::copyInto(std::basic_string<T>& dst, const std::basic_string<T>& src, size_type offset)
 {
-	llassert( offset <= dst.length() );
-
-	// special case - append to end of string and avoid expensive (when strings are large) string manipulations
 	if ( offset == dst.length() )
 	{
+		// special case - append to end of string and avoid expensive
+		// (when strings are large) string manipulations
 		dst += src;
 	}
 	else
@@ -1050,48 +1043,6 @@ BOOL LLStringBase<T>::isHead( const std::basic_string<T>& string, const T* s )
 	}
 }
 
-//static
-template<class T> 
-BOOL LLStringBase<T>::read(std::basic_string<T>& string, const char* filename)	 /*Flawfinder: ignore*/
-{
-	llifstream ifs(filename, llifstream::binary);
-	if (!ifs.is_open())
-	{
-		llinfos << "Unable to open file" << filename << llendl;
-		return FALSE;
-	}
-
-	std::basic_ostringstream<T> oss;
-
-	oss << ifs.rdbuf();
-
-	string = oss.str();
-
-	ifs.close();
-	return TRUE;
-}
-
-//static
-template<class T> 
-BOOL LLStringBase<T>::write(std::basic_string<T>& string, const char* filename)
-{
-#if LL_LINUX  || LL_SOLARIS
-    printf("STUBBED: LLStringBase<T>::write at %s:%d\n", __FILE__, __LINE__);
-#else
-	llofstream ofs(filename, llofstream::binary);
-	if (!ofs.is_open())
-	{
-		llinfos << "Unable to open file" << filename << llendl;
-		return FALSE;
-	}
-
-	ofs << string;
-
-	ofs.close();
-#endif
-	return TRUE;
-}
-
 template<class T> 
 BOOL LLStringBase<T>::convertToBOOL(const std::basic_string<T>& string, BOOL& value)
 {
diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp
index b1b92ae2772..86ec4c0d616 100644
--- a/indra/llcommon/llsys.cpp
+++ b/indra/llcommon/llsys.cpp
@@ -24,10 +24,12 @@
 #	include <winsock2.h>
 #	include <windows.h>
 #elif LL_DARWIN
+#	include <errno.h>
 #	include <sys/sysctl.h>
 #	include <sys/utsname.h>
 #	include <stdint.h>
 #elif LL_LINUX
+#	include <errno.h>
 #	include <sys/utsname.h>
 #	include <unistd.h>
 #	include <sys/sysinfo.h>
diff --git a/indra/llcommon/lltimer.cpp b/indra/llcommon/lltimer.cpp
index 73e73b9c44d..013fab09651 100644
--- a/indra/llcommon/lltimer.cpp
+++ b/indra/llcommon/lltimer.cpp
@@ -16,13 +16,10 @@
 #	define WIN32_LEAN_AND_MEAN
 #	include <winsock2.h>
 #	include <windows.h>
-#	include <time.h>
 #elif LL_LINUX || LL_SOLARIS
-#	include <time.h>
 #	include <sys/time.h>
 #	include <sched.h>
 #elif LL_DARWIN
-#	include <time.h>
 #	include <sys/time.h>
 #else 
 #	error "architecture not supported"
diff --git a/indra/llcommon/lltimer.h b/indra/llcommon/lltimer.h
index 6f67e19c486..e6ea0325147 100644
--- a/indra/llcommon/lltimer.h
+++ b/indra/llcommon/lltimer.h
@@ -10,12 +10,9 @@
 #define LL_TIMER_H
 
 #if LL_LINUX || LL_DARWIN
-#		include <time.h>
-#		include <sys/time.h>
+#include <sys/time.h>
 #endif
 
-#include <list>
-
 // units conversions
 #ifndef USEC_PER_SEC
     const U32	USEC_PER_SEC	= 1000000;
diff --git a/indra/llcommon/stdtypes.h b/indra/llcommon/stdtypes.h
index ccb843061d6..bc069f009da 100644
--- a/indra/llcommon/stdtypes.h
+++ b/indra/llcommon/stdtypes.h
@@ -8,9 +8,6 @@
 #ifndef LL_STDTYPES_H
 #define LL_STDTYPES_H
 
-#include <limits.h>
-#include <float.h>
-
 typedef signed char			S8;
 typedef unsigned char			U8;
 typedef signed short			S16;
diff --git a/indra/llcommon/timing.h b/indra/llcommon/timing.h
index 8952bc3b525..53e7a62a851 100644
--- a/indra/llcommon/timing.h
+++ b/indra/llcommon/timing.h
@@ -9,10 +9,9 @@
 #ifndef LL_TIMING_H					
 #define LL_TIMING_H
 
-#include <time.h>
 
 #if LL_LINUX || LL_DARWIN || LL_SOLARIS
-#		include <sys/time.h>
+#include <sys/time.h>
 #endif
 
 
diff --git a/indra/llimage/llimage.cpp b/indra/llimage/llimage.cpp
index 1ea0ac2714b..ee039aee091 100644
--- a/indra/llimage/llimage.cpp
+++ b/indra/llimage/llimage.cpp
@@ -8,18 +8,12 @@
 
 #include "linden_common.h"
 
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <algorithm>
-#include <iostream>
+#include "llimage.h"
 
 #include "llmath.h"
-#include "stdtypes.h"
 #include "v4coloru.h"
 #include "llmemtype.h"
 
-#include "llimage.h"
 #include "llimagebmp.h"
 #include "llimagetga.h"
 #include "llimagej2c.h"
diff --git a/indra/llimage/llimage.h b/indra/llimage/llimage.h
index 5ffed9fbb16..8db2e9c610e 100644
--- a/indra/llimage/llimage.h
+++ b/indra/llimage/llimage.h
@@ -9,7 +9,6 @@
 #ifndef LL_LLIMAGE_H
 #define LL_LLIMAGE_H
 
-#include "stdtypes.h"
 #include "lluuid.h"
 #include "llstring.h"
 #include "llmemory.h"
diff --git a/indra/llinventory/llinventory.cpp b/indra/llinventory/llinventory.cpp
index 60c1ade38f3..3c32f7b92cc 100644
--- a/indra/llinventory/llinventory.cpp
+++ b/indra/llinventory/llinventory.cpp
@@ -8,8 +8,6 @@
 
 #include "linden_common.h"
 
-#include <time.h>
-
 #include "llinventory.h"
 
 #include "lldbstrings.h"
diff --git a/indra/llinventory/lllandmark.cpp b/indra/llinventory/lllandmark.cpp
index 7cb145d3867..0887d289030 100644
--- a/indra/llinventory/lllandmark.cpp
+++ b/indra/llinventory/lllandmark.cpp
@@ -9,10 +9,7 @@
 #include "linden_common.h"
 #include "lllandmark.h"
 
-#include <stdlib.h>
-#include <string.h>
 #include <errno.h>
-#include <stdio.h>  	// for sscanf() on linux
 
 #include "message.h"
 #include "llregionhandle.h"
diff --git a/indra/llinventory/llparcel.h b/indra/llinventory/llparcel.h
index d50c4f0d3bf..b80fa58cd53 100644
--- a/indra/llinventory/llparcel.h
+++ b/indra/llinventory/llparcel.h
@@ -8,10 +8,6 @@
 #ifndef LL_LLPARCEL_H
 #define LL_LLPARCEL_H
 
-#include <time.h>
-#include <iostream>
-
-#include "lldarray.h"
 #include "lluuid.h"
 #include "llparcelflags.h"
 #include "llpermissions.h"
diff --git a/indra/llinventory/llpermissions.h b/indra/llinventory/llpermissions.h
index 131db1a635f..8c9064306ec 100644
--- a/indra/llinventory/llpermissions.h
+++ b/indra/llinventory/llpermissions.h
@@ -9,9 +9,6 @@
 #ifndef LL_LLPERMISSIONS_H
 #define LL_LLPERMISSIONS_H
 
-#include <stdio.h>
-#include <iostream>
-
 #include "llpermissionsflags.h"
 #include "llsd.h"
 #include "lluuid.h"
diff --git a/indra/llinventory/llsaleinfo.h b/indra/llinventory/llsaleinfo.h
index 2eceea87ef5..30218459d57 100644
--- a/indra/llinventory/llsaleinfo.h
+++ b/indra/llinventory/llsaleinfo.h
@@ -9,9 +9,6 @@
 #ifndef LL_LLSALEINFO_H
 #define LL_LLSALEINFO_H
 
-#include <stdio.h>
-#include <iostream>
-
 #include "llpermissionsflags.h"
 #include "llsd.h"
 #include "llxmlnode.h"
diff --git a/indra/llmath/llmath.h b/indra/llmath/llmath.h
index 5fa74f30f21..21f9d2aeb8b 100644
--- a/indra/llmath/llmath.h
+++ b/indra/llmath/llmath.h
@@ -9,12 +9,6 @@
 #ifndef LLMATH_H
 #define LLMATH_H
 
-#include <cmath>
-#include <math.h>
-#include <stdlib.h>
-
-#include "lldefs.h"
-
 // work around for Windows & older gcc non-standard function names.
 #if LL_WINDOWS
 #define llisnan(val)	_isnan(val)
diff --git a/indra/llmath/v2math.h b/indra/llmath/v2math.h
index 863318551e4..f9af62f8420 100644
--- a/indra/llmath/v2math.h
+++ b/indra/llmath/v2math.h
@@ -9,8 +9,6 @@
 #ifndef LL_V2MATH_H
 #define LL_V2MATH_H
 
-#include <math.h>
-
 #include "llmath.h"
 
 class LLVector4;
diff --git a/indra/llmessage/llassetstorage.cpp b/indra/llmessage/llassetstorage.cpp
index b5a9e8a7278..b848b6488a2 100644
--- a/indra/llmessage/llassetstorage.cpp
+++ b/indra/llmessage/llassetstorage.cpp
@@ -9,11 +9,8 @@
 #include "linden_common.h"
 
 // system library includes
-#include <stdlib.h>
-#include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <algorithm>
 
 #include "llassetstorage.h"
 
diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp
index f1d29250260..ba3a927e92d 100644
--- a/indra/llmessage/llcachename.cpp
+++ b/indra/llmessage/llcachename.cpp
@@ -10,13 +10,6 @@
 
 #include "llcachename.h"
 
-// system includes
-#include <string.h>		// strcpy
-#include <time.h>
-#include <algorithm>
-#include <functional>
-#include <map>
-
 // linden library includes
 #include "message.h"
 #include "llrand.h"
diff --git a/indra/llmessage/llcachename.h b/indra/llmessage/llcachename.h
index 3c8a6587b13..5580c314c03 100644
--- a/indra/llmessage/llcachename.h
+++ b/indra/llmessage/llcachename.h
@@ -9,9 +9,6 @@
 #ifndef LL_LLCACHENAME_H
 #define LL_LLCACHENAME_H
 
-// Forward declarations
-#include <stdio.h>
-
 class LLMessageSystem;
 class LLHost;
 class LLUUID;
diff --git a/indra/llmessage/lldatapacker.cpp b/indra/llmessage/lldatapacker.cpp
index 74a6a871c06..2d1822a337c 100644
--- a/indra/llmessage/lldatapacker.cpp
+++ b/indra/llmessage/lldatapacker.cpp
@@ -6,8 +6,6 @@
  * $License$
  */
 
-#include <string.h>
-
 #include "linden_common.h"
 
 #include "lldatapacker.h"
diff --git a/indra/llmessage/lldatapacker.h b/indra/llmessage/lldatapacker.h
index 01c3ebb347c..b288ec67ddf 100644
--- a/indra/llmessage/lldatapacker.h
+++ b/indra/llmessage/lldatapacker.h
@@ -9,11 +9,6 @@
 #ifndef LL_LLDATAPACKER_H 
 #define LL_LLDATAPACKER_H
 
-#include <stdio.h>
-#include <iostream>
-
-#include "llerror.h"
-
 class LLColor4;
 class LLColor4U;
 class LLVector2;
diff --git a/indra/llmessage/llnamevalue.h b/indra/llmessage/llnamevalue.h
index f3d0d0d3387..82217f700e5 100644
--- a/indra/llmessage/llnamevalue.h
+++ b/indra/llmessage/llnamevalue.h
@@ -9,13 +9,9 @@
 #ifndef LL_LLNAMEVALUE_H
 #define LL_LLNAMEVALUE_H
 
-#include <iostream>
-#include <string.h>
-
 #include "string_table.h"
 #include "llskipmap.h"
 #include "llmath.h"
-//#include "vmath.h"
 #include "v3math.h"
 #include "lldbstrings.h"
 
diff --git a/indra/llmessage/llpartdata.h b/indra/llmessage/llpartdata.h
index 662d635a088..18e049ae7a7 100644
--- a/indra/llmessage/llpartdata.h
+++ b/indra/llmessage/llpartdata.h
@@ -9,8 +9,6 @@
 #ifndef LL_LLPARTDATA_H
 #define LL_LLPARTDATA_H
 
-#include <stdio.h>
-
 #include "lluuid.h"
 #include "v3math.h"
 #include "v3dmath.h"
diff --git a/indra/llmessage/llregionhandle.h b/indra/llmessage/llregionhandle.h
index 41d104231c7..82385792622 100644
--- a/indra/llmessage/llregionhandle.h
+++ b/indra/llmessage/llregionhandle.h
@@ -9,8 +9,6 @@
 #ifndef LL_LLREGIONHANDLE_H
 #define LL_LLREGIONHANDLE_H
 
-#include <math.h>
-
 #include "indra_constants.h"
 #include "v3math.h"
 #include "v3dmath.h"
diff --git a/indra/llmessage/lltransfersourcefile.h b/indra/llmessage/lltransfersourcefile.h
index fcb5743fb5b..eb0ff6f7774 100644
--- a/indra/llmessage/lltransfersourcefile.h
+++ b/indra/llmessage/lltransfersourcefile.h
@@ -11,8 +11,6 @@
 
 #include "lltransfermanager.h"
 
-#include <stdio.h>
-
 class LLTransferSourceParamsFile : public LLTransferSourceParams
 {
 public:
diff --git a/indra/llmessage/lltransfertargetfile.h b/indra/llmessage/lltransfertargetfile.h
index eb000e527e8..628bce7e3ff 100644
--- a/indra/llmessage/lltransfertargetfile.h
+++ b/indra/llmessage/lltransfertargetfile.h
@@ -11,8 +11,6 @@
 
 #include "lltransfermanager.h"
 
-#include <stdio.h>
-
 typedef void (*LLTTFCompleteCallback)(const LLTSCode status, void *user_data);
 
 class LLTransferTargetParamsFile : public LLTransferTargetParams
diff --git a/indra/llmessage/llxfer_file.h b/indra/llmessage/llxfer_file.h
index 38c94f6591a..80f6526dd7c 100644
--- a/indra/llmessage/llxfer_file.h
+++ b/indra/llmessage/llxfer_file.h
@@ -9,8 +9,6 @@
 #ifndef LL_LLXFER_FILE_H
 #define LL_LLXFER_FILE_H
 
-#include <stdio.h>
-
 #include "llxfer.h"
 #include "lldir.h"
 
diff --git a/indra/llmessage/llxfer_mem.h b/indra/llmessage/llxfer_mem.h
index 6577132c9b8..05a38af7b71 100644
--- a/indra/llmessage/llxfer_mem.h
+++ b/indra/llmessage/llxfer_mem.h
@@ -9,8 +9,6 @@
 #ifndef LL_LLXFER_MEM_H
 #define LL_LLXFER_MEM_H
 
-#include <stdio.h>
-
 #include "message.h"
 #include "lltimer.h"
 #include "llxfer.h"
diff --git a/indra/llmessage/llxfer_vfile.h b/indra/llmessage/llxfer_vfile.h
index a5dce0352c7..552f05ce773 100644
--- a/indra/llmessage/llxfer_vfile.h
+++ b/indra/llmessage/llxfer_vfile.h
@@ -9,8 +9,6 @@
 #ifndef LL_LLXFER_VFILE_H
 #define LL_LLXFER_VFILE_H
 
-#include <stdio.h>
-
 #include "llxfer.h"
 #include "llassetstorage.h"
 
diff --git a/indra/llmessage/mean_collision_data.h b/indra/llmessage/mean_collision_data.h
index 7d3f90cde6f..48df6995619 100644
--- a/indra/llmessage/mean_collision_data.h
+++ b/indra/llmessage/mean_collision_data.h
@@ -10,8 +10,8 @@
 #ifndef LL_MEAN_COLLISIONS_DATA_H
 #define LL_MEAN_COLLISIONS_DATA_H
 
-#include <time.h>
 #include "lldbstrings.h"
+#include "lluuid.h"
 
 const F32 MEAN_COLLISION_TIMEOUT = 5.f;
 const S32 MAX_MEAN_COLLISIONS = 5;
diff --git a/indra/llmessage/message.cpp b/indra/llmessage/message.cpp
index 5077354533e..7f9f440c80d 100644
--- a/indra/llmessage/message.cpp
+++ b/indra/llmessage/message.cpp
@@ -18,10 +18,6 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <cstring>
-#include <time.h>
 #include <iomanip>
 #include <iterator>
 #include <sstream>
@@ -355,8 +351,8 @@ void LLMessageSystem::loadTemplateFile(const char* filename)
 		return;
 	}
 
-	LLString template_body;
-	if(!LLString::read(template_body, filename))
+	std::string template_body;
+	if(!_read_file_into_string(template_body, filename))
 	{
 		llwarns << "Failed to open template: " << filename << llendl;
 		mbError = TRUE;
diff --git a/indra/llmessage/message.h b/indra/llmessage/message.h
index 2f875f2b965..04bc058cb67 100644
--- a/indra/llmessage/message.h
+++ b/indra/llmessage/message.h
@@ -10,8 +10,6 @@
 #define LL_MESSAGE_H
 
 #include <cstring>
-#include <stdio.h>
-#include <map>
 #include <set>
 
 #if LL_LINUX
diff --git a/indra/llmessage/net.cpp b/indra/llmessage/net.cpp
index 2d3215f47c4..615af0915a4 100644
--- a/indra/llmessage/net.cpp
+++ b/indra/llmessage/net.cpp
@@ -12,7 +12,6 @@
 
 // system library includes
 #include <stdexcept>
-#include <stdio.h>
 
 #if LL_WINDOWS
 	#define WIN32_LEAN_AND_MEAN
diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index b87d82653aa..65e6a4921ba 100644
--- a/indra/llui/llview.cpp
+++ b/indra/llui/llview.cpp
@@ -11,23 +11,21 @@
 
 #include "llview.h"
 
-#include "llstring.h"
-#include "llrect.h"
-#include "llgl.h"
+#include <cassert>
+#include <boost/tokenizer.hpp>
+
 #include "llevent.h"
 #include "llfontgl.h"
 #include "llfocusmgr.h"
+#include "llgl.h"
 #include "llglheaders.h"
-#include "llwindow.h"
+#include "llrect.h"
 #include "llstl.h"
-#include "lluictrl.h"
 #include "llui.h"	// colors saved settings
+#include "lluictrl.h"
+#include "llwindow.h"
 #include "v3color.h"
-#include "llstl.h"
-
-#include <boost/tokenizer.hpp>
 
-#include <assert.h>
 
 BOOL	LLView::sDebugRects = FALSE;
 BOOL	LLView::sDebugKeys = FALSE;
diff --git a/indra/llui/llview.h b/indra/llui/llview.h
index 18f453f6217..94586bf4fac 100644
--- a/indra/llui/llview.h
+++ b/indra/llui/llview.h
@@ -13,23 +13,19 @@
 // the HUD or a dialog box or a button.  It can also contain sub-views
 // and child widgets
 
-#include <iosfwd>
-#include <list>
-
-#include "lluixmltags.h"
-#include "llrect.h"
+#include "llcoord.h"
+#include "llfontgl.h"
+#include "llmortician.h"
 #include "llmousehandler.h"
-#include "stdenums.h"
+#include "llnametable.h"
 #include "llsd.h"
 #include "llstring.h"
-#include "llnametable.h"
-#include "llcoord.h"
-#include "llmortician.h"
-#include "llxmlnode.h"
-#include "llfontgl.h"
-#include "llviewquery.h"
-
+#include "llrect.h"
 #include "llui.h"
+#include "lluixmltags.h"
+#include "llviewquery.h"
+#include "llxmlnode.h"
+#include "stdenums.h"
 
 class LLColor4;
 class LLWindow;
diff --git a/indra/llvfs/lldir.cpp b/indra/llvfs/lldir.cpp
index 94c1b5de245..5203e31ff93 100644
--- a/indra/llvfs/lldir.cpp
+++ b/indra/llvfs/lldir.cpp
@@ -11,6 +11,7 @@
 #if !LL_WINDOWS
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <errno.h>
 #else
 #include <direct.h>
 #endif
diff --git a/indra/llvfs/lldir_linux.h b/indra/llvfs/lldir_linux.h
index 3e63e723035..767c8b34759 100644
--- a/indra/llvfs/lldir_linux.h
+++ b/indra/llvfs/lldir_linux.h
@@ -11,7 +11,6 @@
 
 #include "lldir.h"
 
-#include <stdio.h>
 #include <dirent.h>
 #include <errno.h>
 
diff --git a/indra/llvfs/lldir_mac.h b/indra/llvfs/lldir_mac.h
index 1375f142f49..9815e3afacd 100644
--- a/indra/llvfs/lldir_mac.h
+++ b/indra/llvfs/lldir_mac.h
@@ -11,7 +11,6 @@
 
 #include "lldir.h"
 
-#include <stdio.h>
 #include <dirent.h>
 
 class LLDir_Mac : public LLDir
diff --git a/indra/llvfs/lldir_solaris.h b/indra/llvfs/lldir_solaris.h
index 1ab76230ee2..ad3bc4525b7 100644
--- a/indra/llvfs/lldir_solaris.h
+++ b/indra/llvfs/lldir_solaris.h
@@ -11,7 +11,6 @@
 
 #include "lldir.h"
 
-#include <stdio.h>
 #include <dirent.h>
 #include <errno.h>
 
diff --git a/indra/llvfs/llvfs.cpp b/indra/llvfs/llvfs.cpp
index 0054e877559..f599ae122b7 100644
--- a/indra/llvfs/llvfs.cpp
+++ b/indra/llvfs/llvfs.cpp
@@ -8,9 +8,7 @@
 
 #include "linden_common.h"
 
-#include <stdio.h>
 #include <sys/stat.h>
-#include <time.h>
 #include <set>
 #include <map>
 #if LL_WINDOWS
diff --git a/indra/llvfs/llvfs.h b/indra/llvfs/llvfs.h
index 5089e059e8a..d18797fe4ec 100644
--- a/indra/llvfs/llvfs.h
+++ b/indra/llvfs/llvfs.h
@@ -9,8 +9,6 @@
 #ifndef LL_LLVFS_H
 #define LL_LLVFS_H
 
-#include <stdio.h>
-#include <map>
 #include <deque>
 #include "lluuid.h"
 #include "linked_lists.h"
diff --git a/indra/llwindow/lldxhardware.cpp b/indra/llwindow/lldxhardware.cpp
index dc3edadb9c0..35b7384c2f1 100644
--- a/indra/llwindow/lldxhardware.cpp
+++ b/indra/llwindow/lldxhardware.cpp
@@ -12,7 +12,6 @@
 
 #include "linden_common.h"
 
-#include <assert.h>
 #include <dxdiag.h>
 
 #include <boost/tokenizer.hpp>
diff --git a/indra/lscript/lscript_alloc.h b/indra/lscript/lscript_alloc.h
index c9eca7cd819..827156a9e37 100644
--- a/indra/lscript/lscript_alloc.h
+++ b/indra/lscript/lscript_alloc.h
@@ -12,11 +12,8 @@
 // Under gcc 2.9, the manual is unclear if comments can appear above #ifndef
 // Under gcc 3, the manual explicitly states comments can appear above the #ifndef
 
-#include "stdtypes.h"
 #include "lscript_byteconvert.h"
 #include "lscript_library.h"
-#include "llrand.h"
-#include <stdio.h>
 
 void reset_hp_to_safe_spot(const U8 *buffer);
 
diff --git a/indra/lscript/lscript_compile/indra.l b/indra/lscript/lscript_compile/indra.l
index a8fbcbe260e..ee3492b0714 100644
--- a/indra/lscript/lscript_compile/indra.l
+++ b/indra/lscript/lscript_compile/indra.l
@@ -9,13 +9,15 @@ FS			(f|F)
 %p 5000
 
 %{
-#include <stdio.h>
-#include "stdtypes.h"
+#include "linden_common.h"
+// Deal with the fact that lex/yacc generates unreachable code
+#ifdef LL_WINDOWS
+#pragma warning (disable : 4702) // warning C4702: unreachable code
+#endif	//	LL_WINDOWS
 #include "llmath.h"
 #include "lscript_tree.h"
 #include "lscript_typecheck.h"
 #include "lscript_resource.h"
-#include "llfile.h"
 #if LL_WINDOWS
 #include "ytab.h"
 #else
diff --git a/indra/lscript/lscript_compile/indra.y b/indra/lscript/lscript_compile/indra.y
index 56f40c974c9..d10cbfedba2 100644
--- a/indra/lscript/lscript_compile/indra.y
+++ b/indra/lscript/lscript_compile/indra.y
@@ -1,7 +1,7 @@
 %{
-	#include "stdtypes.h"
+	#include "linden_common.h"
 	#include "lscript_tree.h"
-	
+
     #ifdef __cplusplus
     extern "C" {
     #endif
@@ -16,6 +16,7 @@
     #endif
 
     #ifdef LL_WINDOWS
+	#pragma warning (disable : 4702) // warning C4702: unreachable code
 	#pragma warning( disable : 4065 )	// warning: switch statement contains 'default' but no 'case' labels
 	#endif
 
diff --git a/indra/lscript/lscript_compile/lscript_error.h b/indra/lscript/lscript_compile/lscript_error.h
index 4ad7b60dd8d..9e76b9a4d7d 100644
--- a/indra/lscript/lscript_compile/lscript_error.h
+++ b/indra/lscript/lscript_compile/lscript_error.h
@@ -9,11 +9,8 @@
 #ifndef LL_LSCRIPT_ERROR_H
 #define LL_LSCRIPT_ERROR_H
 
-#include <stdio.h>
-#include "stdtypes.h"
 #include "lscript_scope.h"
 
-
 typedef enum e_lscript_compile_pass
 {
 	LSCP_INVALID,
diff --git a/indra/lscript/lscript_compile/lscript_resource.h b/indra/lscript/lscript_compile/lscript_resource.h
index b0a38b81fb2..36de4786c6d 100644
--- a/indra/lscript/lscript_compile/lscript_resource.h
+++ b/indra/lscript/lscript_compile/lscript_resource.h
@@ -9,8 +9,6 @@
 #ifndef LL_LSCRIPT_RESOURCE_H
 #define LL_LSCRIPT_RESOURCE_H
 
-#include <stdio.h>
-#include "stdtypes.h"
 #include "lscript_scope.h"
 
 void init_temp_jumps();
diff --git a/indra/lscript/lscript_compile/lscript_tree.h b/indra/lscript/lscript_compile/lscript_tree.h
index d0e8bcf389b..a1fe4f4d09c 100644
--- a/indra/lscript/lscript_compile/lscript_tree.h
+++ b/indra/lscript/lscript_compile/lscript_tree.h
@@ -9,8 +9,6 @@
 #ifndef LL_LSCRIPT_TREE_H
 #define LL_LSCRIPT_TREE_H
 
-#include <stdio.h>
-#include "stdtypes.h"
 #include "v3math.h"
 #include "llquaternion.h"
 #include "linked_lists.h"
diff --git a/indra/lscript/lscript_execute.h b/indra/lscript/lscript_execute.h
index 1c2952f5ae2..fe3784f19fd 100644
--- a/indra/lscript/lscript_execute.h
+++ b/indra/lscript/lscript_execute.h
@@ -9,7 +9,6 @@
 #ifndef LL_LSCRIPT_EXECUTE_H
 #define LL_LSCRIPT_EXECUTE_H
 
-#include <stdio.h>
 #include "lscript_byteconvert.h"
 #include "linked_lists.h"
 #include "lscript_library.h"
diff --git a/indra/lscript/lscript_library.h b/indra/lscript/lscript_library.h
index b5fdfc7a227..c7544044cca 100644
--- a/indra/lscript/lscript_library.h
+++ b/indra/lscript/lscript_library.h
@@ -14,7 +14,6 @@
 #include "llquaternion.h"
 #include "lluuid.h"
 #include "lscript_byteconvert.h"
-#include <stdio.h>
 
 class LLScriptLibData;
 
diff --git a/indra/lscript/lscript_library/lscript_alloc.cpp b/indra/lscript/lscript_library/lscript_alloc.cpp
index d98af1ddf34..b80f74870bc 100644
--- a/indra/lscript/lscript_library/lscript_alloc.cpp
+++ b/indra/lscript/lscript_library/lscript_alloc.cpp
@@ -11,8 +11,8 @@
 // Under gcc 3, the manual explicitly states comments can appear above the #ifndef
 
 #include "linden_common.h"
-
 #include "lscript_alloc.h"
+#include "llrand.h"
 
 // supported data types
 
diff --git a/indra/mac_crash_logger/mac_crash_logger.cpp b/indra/mac_crash_logger/mac_crash_logger.cpp
index 4d6e8314b3c..f790438eedd 100644
--- a/indra/mac_crash_logger/mac_crash_logger.cpp
+++ b/indra/mac_crash_logger/mac_crash_logger.cpp
@@ -8,10 +8,6 @@
 
 #include "linden_common.h"
 
-#include <stdio.h>
-#include <stdlib.h>
-//#include <direct.h>
-#include <time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
diff --git a/indra/mac_updater/mac_updater.cpp b/indra/mac_updater/mac_updater.cpp
index ecef6e6b77f..76014a2e1d3 100644
--- a/indra/mac_updater/mac_updater.cpp
+++ b/indra/mac_updater/mac_updater.cpp
@@ -8,10 +8,6 @@
 
 #include "linden_common.h"
 
-#include <stdio.h>
-#include <stdlib.h>
-//#include <direct.h>
-#include <time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
diff --git a/indra/newview/llfloaterland.cpp b/indra/newview/llfloaterland.cpp
index e0ceedf0f71..be410196c5c 100644
--- a/indra/newview/llfloaterland.cpp
+++ b/indra/newview/llfloaterland.cpp
@@ -9,7 +9,6 @@
 #include "llviewerprecompiledheaders.h"
 
 #include <sstream>
-#include <time.h>
 
 #include "llfloaterland.h"
 
diff --git a/indra/newview/llpanelland.cpp b/indra/newview/llpanelland.cpp
index 9363b98d120..c16eb83887e 100644
--- a/indra/newview/llpanelland.cpp
+++ b/indra/newview/llpanelland.cpp
@@ -8,8 +8,6 @@
 
 #include "llviewerprecompiledheaders.h"
 
-#include <time.h>
-
 #include "llpanelland.h"
 
 #include "llparcel.h"
diff --git a/indra/newview/llurl.cpp b/indra/newview/llurl.cpp
index 73444f611d6..19d100a561c 100644
--- a/indra/newview/llurl.cpp
+++ b/indra/newview/llurl.cpp
@@ -7,7 +7,6 @@
  */
 
 #include "llviewerprecompiledheaders.h"
-#include <string.h>
 #include "llurl.h"
 #include "llerror.h"
 
diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp
index c09dd03dd41..43cf132b57b 100644
--- a/indra/newview/llviewermessage.cpp
+++ b/indra/newview/llviewermessage.cpp
@@ -11,8 +11,6 @@
 #include "llviewermessage.h"
 
 #include <deque>
-#include <stdio.h>
-#include <string.h>
 
 #include "audioengine.h" 
 #include "audiosettings.h"
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index d4b87ceba0b..afdd762404b 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -8,11 +8,6 @@
 
 #include "llviewerprecompiledheaders.h"
 
-// system library includes
-#include <stdio.h>
-#include <iostream>
-#include <fstream>
-
 #include "llviewerwindow.h"
 #include "llviewquery.h"
 #include "llxmltree.h"
diff --git a/indra/test/llblowfish_tut.cpp b/indra/test/llblowfish_tut.cpp
index 8f0912d98de..306b66a39d2 100644
--- a/indra/test/llblowfish_tut.cpp
+++ b/indra/test/llblowfish_tut.cpp
@@ -16,8 +16,6 @@
 
 #include "llblowfishcipher.h"
 
-#include <string>
-#include <stdio.h>
 #include "lluuid.h"
 
 namespace tut
diff --git a/indra/test/llbuffer_tut.cpp b/indra/test/llbuffer_tut.cpp
index 4ac72d59d35..f7737464da7 100644
--- a/indra/test/llbuffer_tut.cpp
+++ b/indra/test/llbuffer_tut.cpp
@@ -9,6 +9,7 @@
  */
 
 #include <tut/tut.h>
+#include "linden_common.h"
 #include "lltut.h"
 #include "llbuffer.h"
 #include "llerror.h"
diff --git a/indra/test/llhttpdate_tut.cpp b/indra/test/llhttpdate_tut.cpp
index 2a82155cd1f..f491f08e781 100644
--- a/indra/test/llhttpdate_tut.cpp
+++ b/indra/test/llhttpdate_tut.cpp
@@ -13,9 +13,6 @@
 #include "lldate.h"
 #include "llframetimer.h"
 
-#include <string>
-#include <time.h>
-
 namespace tut
 {
     struct httpdate_data
diff --git a/indra/test/llhttpnode_tut.cpp b/indra/test/llhttpnode_tut.cpp
index 30165cb769c..fb94eb3287c 100644
--- a/indra/test/llhttpnode_tut.cpp
+++ b/indra/test/llhttpnode_tut.cpp
@@ -7,9 +7,8 @@
  * $License$
  */
 
-#include <tut/tut.h>
+#include "linden_common.h"
 #include "lltut.h"
-
 #include "llhttpnode.h"
 #include "llsdhttpserver.h"
 
diff --git a/indra/test/lliohttpserver_tut.cpp b/indra/test/lliohttpserver_tut.cpp
index e0001438c7b..d5e1d32ffc8 100644
--- a/indra/test/lliohttpserver_tut.cpp
+++ b/indra/test/lliohttpserver_tut.cpp
@@ -7,9 +7,8 @@
  * $License$
  */
 
-#include <tut/tut.h>
+#include "linden_common.h"
 #include "lltut.h"
-
 #include "llbufferstream.h"
 #include "lliohttpserver.h"
 #include "llsdhttpserver.h"
diff --git a/indra/test/llmessageconfig_tut.cpp b/indra/test/llmessageconfig_tut.cpp
index 30a799a1bf8..6e07671c8d2 100644
--- a/indra/test/llmessageconfig_tut.cpp
+++ b/indra/test/llmessageconfig_tut.cpp
@@ -7,9 +7,9 @@
  * $License$
  */
 
-#include <tut/tut.h>
-#include "lltut.h"
+#include "linden_common.h"
 #include "llmessageconfig.h"
+#include "lltut.h"
 #include "llsdserialize.h"
 #include "llfile.h"
 #include "lldir.h"
diff --git a/indra/test/llmessagetemplateparser_tut.cpp b/indra/test/llmessagetemplateparser_tut.cpp
index 1faa4e90cbe..8bb23009ced 100644
--- a/indra/test/llmessagetemplateparser_tut.cpp
+++ b/indra/test/llmessagetemplateparser_tut.cpp
@@ -7,10 +7,9 @@
  * $License$
  */
 
-#include <tut/tut.h>
-#include "lltut.h"
 #include "linden_common.h"
 #include "llmessagetemplateparser.h"
+#include "lltut.h"
 
 namespace tut
 {
diff --git a/indra/test/llsaleinfo_tut.cpp b/indra/test/llsaleinfo_tut.cpp
index ef6e1cc94b4..16920082c51 100644
--- a/indra/test/llsaleinfo_tut.cpp
+++ b/indra/test/llsaleinfo_tut.cpp
@@ -9,8 +9,8 @@
  */
 
 #include <tut/tut.h>
-#include "lltut.h"
 #include "linden_common.h"
+#include "lltut.h"
 #include "llsaleinfo.h"
 
 namespace tut
diff --git a/indra/test/llsd_new_tut.cpp b/indra/test/llsd_new_tut.cpp
index 0ceb4302ffc..7a1ac9ab494 100644
--- a/indra/test/llsd_new_tut.cpp
+++ b/indra/test/llsd_new_tut.cpp
@@ -7,7 +7,6 @@
  * $License$
  */
 
-#include <math.h>
 #include <tut/tut.h>
 #include "linden_common.h"
 #include "lltut.h"
diff --git a/indra/test/llsdmessagebuilder_tut.cpp b/indra/test/llsdmessagebuilder_tut.cpp
index 900de1f2ddb..938293434e1 100755
--- a/indra/test/llsdmessagebuilder_tut.cpp
+++ b/indra/test/llsdmessagebuilder_tut.cpp
@@ -8,8 +8,9 @@
  */
 
 #include <tut/tut.h>
-#include "lltut.h"
 
+#include "linden_common.h"
+#include "lltut.h"
 #include "llsdmessagebuilder.h"
 #include "llsdmessagereader.h"
 #include "llsdtraits.h"
diff --git a/indra/test/llservicebuilder_tut.cpp b/indra/test/llservicebuilder_tut.cpp
index e782cfbb6f1..759281e8a60 100644
--- a/indra/test/llservicebuilder_tut.cpp
+++ b/indra/test/llservicebuilder_tut.cpp
@@ -8,8 +8,9 @@
 */
 
 #include <tut/tut.h>
-#include "lltut.h"
 
+#include "linden_common.h"
+#include "lltut.h"
 #include "llsd.h"
 #include "llservicebuilder.h"
 
diff --git a/indra/test/llstreamtools_tut.cpp b/indra/test/llstreamtools_tut.cpp
index 17e5c7cc2c0..b3d03375fa2 100644
--- a/indra/test/llstreamtools_tut.cpp
+++ b/indra/test/llstreamtools_tut.cpp
@@ -9,7 +9,8 @@
  */
  
 #include <tut/tut.h>
-#include <fstream>
+
+#include "linden_common.h"
 #include "llstreamtools.h"
 #include "lltut.h"
 
diff --git a/indra/test/llxorcipher_tut.cpp b/indra/test/llxorcipher_tut.cpp
index 6fe5176cb04..3fd4e3ad972 100644
--- a/indra/test/llxorcipher_tut.cpp
+++ b/indra/test/llxorcipher_tut.cpp
@@ -8,7 +8,7 @@
  * $License$
  */
  
-#include <tut/tut.h>
+#include "linden_common.h"
 #include "lltut.h"
 #include "llxorcipher.h"
 #include "llnullcipher.h"
diff --git a/indra/win_crash_logger/win_crash_logger.cpp b/indra/win_crash_logger/win_crash_logger.cpp
index 8760ae43f82..38f7973748c 100644
--- a/indra/win_crash_logger/win_crash_logger.cpp
+++ b/indra/win_crash_logger/win_crash_logger.cpp
@@ -16,10 +16,7 @@
 #include "llcontrol.h"
 #include "resource.h"
 
-#include <stdio.h>
-#include <stdlib.h>
 #include <direct.h>
-#include <time.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <wininet.h>
diff --git a/indra/win_updater/updater.cpp b/indra/win_updater/updater.cpp
index 536553a4ed9..a0761b0cc58 100644
--- a/indra/win_updater/updater.cpp
+++ b/indra/win_updater/updater.cpp
@@ -10,14 +10,11 @@
 // Usage: updater -url <url> [-name <window_title>] [-program <program_name>] [-silent]
 //
 
+#include "linden_common.h"
+
 #include <windows.h>
 #include <wininet.h>
 
-#include <stdio.h>
-#include <stdarg.h>
-#include "llpreprocessor.h"
-#include "llfile.h"
-
 #define BUFSIZE 8192
 
 int  gTotalBytesRead = 0;
-- 
GitLab