This is the mail archive of the cygwin-cvs@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[newlib-cygwin] Cygwin: Remove workaround in environ.cc


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=3a049236dbb426f63b6182253c04fb9811848dc5

commit 3a049236dbb426f63b6182253c04fb9811848dc5
Author: Ken Brown <kbrown@cornell.edu>
Date:   Wed Jun 6 11:45:57 2018 -0400

    Cygwin: Remove workaround in environ.cc
    
    Commit ebd645e on 2001-10-03 made environ.cc:_addenv() add unneeded
    space at the end of the environment block to "work around problems
    with some buggy applications."  This clutters the code and is
    presumably no longer needed.

Diff:
---
 winsup/cygwin/environ.cc | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index bbe5398..67ead1d 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -592,13 +592,11 @@ _addenv (const char *name, const char *value, int overwrite)
     {				/* Create new slot. */
       int sz = envsize (cur_environ ());
 
-      /* If sz == 0, we need two new slots, one for the terminating NULL.
-	 But we add two slots in all cases, as has been done since
-	 2001-10-03 (commit ebd645e) to "work around problems with
-	 some buggy applications." */
-      int allocsz = (sz + 2) * sizeof (char *);
+      /* If sz == 0, we need two new slots, one for the terminating NULL. */
+      int newsz = sz == 0 ? 2 : sz + 1;
+      int allocsz = newsz * sizeof (char *);
 
-      offset = sz == 0 ? 0 : sz - 1;
+      offset = newsz - 2;
 
       /* Allocate space for additional element. */
       if (cur_environ () == lastenviron)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]