|
Boost-Commit : |
From: lists.drrngrvy_at_[hidden]
Date: 2007-08-25 13:32:24
Author: drrngrvy
Date: 2007-08-25 13:32:24 EDT (Sat, 25 Aug 2007)
New Revision: 38943
URL: http://svn.boost.org/trac/boost/changeset/38943
Log:
Moving `extern char** environ` outside cgi::detail namespace, as it seems to break MSVC under certain conditions.
Text files modified:
sandbox/SOC/2007/cgi/boost/cgi/detail/save_environment.hpp | 45 ++++++++++++++++++++++++++++++++++-----
sandbox/SOC/2007/cgi/boost/cgi/detail/service_base.hpp | 4 ---
sandbox/SOC/2007/cgi/boost/cgi/detail/service_id.hpp | 6 ----
3 files changed, 40 insertions(+), 15 deletions(-)
Modified: sandbox/SOC/2007/cgi/boost/cgi/detail/save_environment.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/detail/save_environment.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/detail/save_environment.hpp 2007-08-25 13:32:24 EDT (Sat, 25 Aug 2007)
@@ -9,20 +9,26 @@
#ifndef CGI_DETAIL_SAVE_ENVIRONMENT_HPP_INCLUDED__
#define CGI_DETAIL_SAVE_ENVIRONMENT_HPP_INCLUDED__
+#include <map>
#include <string>
#include <cstdlib>
#include "boost/cgi/map.hpp"
+ // The process' environment
+ extern char** environ;
+
namespace cgi {
namespace detail {
- // The process' environment
- extern char** environ;
-
- /// Save all information from the process' environment variables to env_map
- void save_environment(cgi::map& env_map)
+ /// Save all information from `environment` to env_map
+ /**
+ * @param env This defaults to `::environ`, or the current process'
+ * environment.
+ */
+ void save_environment(std::map<std::string,std::string>& env_map
+ , char** env = ::environ)
{
- for(char** env = ::environ; *env; ++env)
+ for(; *env; ++env)
{
int i=0;
int j=strlen(*env);
@@ -30,6 +36,8 @@
if ((*env)[i] == '=')
break;
+ // Note: empty variables are not guaranteed to be set by the server, so
+ // we are free to ignore them too.
if ((*env)[i+1] != '\0')
{
std::string sa(*env, i);
@@ -42,4 +50,29 @@
} // namespace detail
} // namespace cgi
+/* Alternative version which doesn't copy the 'value' of the variable
+ ******************************************************************************
+ void save_environment(std::map<std::string,const char*>& env_map
+ , char** env = ::environ)
+ {
+ for(; *env; ++env)
+ {
+ int i=0;
+ int j=strlen(*env);
+ for(; i < j; ++i)
+ if ((*env)[i] == '=')
+ break;
+
+ // Note: empty variables are not guaranteed to be set by the server, so
+ // we are free to ignore them too.
+ if ((*env)[i+1] != '\0')
+ {
+ std::string sa(*env, i);
+ env_map[sa] = (*env+i+1);
+ }
+ }
+ }
+ ******************************************************************************
+ */
+
#endif // CGI_DETAIL_SAVE_ENVIRONMENT_HPP_INCLUDED__
Modified: sandbox/SOC/2007/cgi/boost/cgi/detail/service_base.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/detail/service_base.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/detail/service_base.hpp 2007-08-25 13:32:24 EDT (Sat, 25 Aug 2007)
@@ -12,10 +12,6 @@
#ifndef CGI_DETAIL_SERVICE_ID_HPP_INCLUDED__
#define CGI_DETAIL_SERVICE_ID_HPP_INCLUDED__
-#if defined(_MSC_VER) && (_MSC_VER >= 1200)
-# pragma once
-#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
-
#include <boost/asio/detail/push_options.hpp>
#include <boost/asio/io_service.hpp>
Modified: sandbox/SOC/2007/cgi/boost/cgi/detail/service_id.hpp
==============================================================================
--- sandbox/SOC/2007/cgi/boost/cgi/detail/service_id.hpp (original)
+++ sandbox/SOC/2007/cgi/boost/cgi/detail/service_id.hpp 2007-08-25 13:32:24 EDT (Sat, 25 Aug 2007)
@@ -1,5 +1,5 @@
// -- service_id.hpp --
-// (taken from Boost.Asio)
+// (taken from Boost.Asio)
//
// Copyright (c) 2003-2007 Christopher M. Kohlhoff
// (chris at kohlhoff dot com)
@@ -12,10 +12,6 @@
#ifndef CGI_DETAIL_SERVICE_ID_HPP_INCLUDED__
#define CGI_DETAIL_SERVICE_ID_HPP_INCLUDED__
-#if defined(_MSC_VER) && (_MSC_VER >= 1200)
-# pragma once
-#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
-
#include <boost/asio/detail/push_options.hpp>
#include <boost/asio/io_service.hpp>
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk