public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] drop MAXPATHLEN dependency from gcc/tlink.c
@ 2007-07-24 21:19 Samuel Thibault
  2007-08-01  1:39 ` Ian Lance Taylor
  0 siblings, 1 reply; 8+ messages in thread
From: Samuel Thibault @ 2007-07-24 21:19 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 153 bytes --]

Hi,

Some systems don't define MAXPATHLEN because they don't have such hard
limit.  Here is a patch against gcc/tlink.c to take benefit of this.

Samuel

[-- Attachment #2: patch --]
[-- Type: text/plain, Size: 1162 bytes --]

2007-07-24  Samuel Thibault  <samuel.thibault@ens-lyon.org>

	* gcc/tlink.c (initial_cwd): Change type into char*.
	(tlink_init): Add loop to dynamically allocate initial_cwd as needed.

Index: gcc/tlink.c
===================================================================
--- gcc/tlink.c	(révision 126889)
+++ gcc/tlink.c	(copie de travail)
@@ -31,6 +31,7 @@
 #include "hashtab.h"
 #include "demangle.h"
 #include "collect2.h"
+#include "libiberty.h"
 
 #define MAX_ITERATIONS 17
 
@@ -39,7 +40,7 @@
 
 static int tlink_verbose;
 
-static char initial_cwd[MAXPATHLEN + 1];
+static char *initial_cwd;
 \f
 /* Hash table boilerplate for working with htab_t.  We have hash tables
    for symbol names, file names, and demangled symbols.  */
@@ -252,6 +253,7 @@
 tlink_init (void)
 {
   const char *p;
+  size_t size = 128;
 
   symbol_table = htab_create (500, hash_string_hash, hash_string_eq,
 			      NULL);
@@ -275,7 +277,12 @@
 	tlink_verbose = 3;
     }
 
-  getcwd (initial_cwd, sizeof (initial_cwd));
+  while (1) {
+    initial_cwd = xrealloc (initial_cwd, size);
+    if (getcwd (initial_cwd, size))
+      break;
+    size *= 2;
+  }
 }
 
 static int

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-08-13 20:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-24 21:19 [PATCH] drop MAXPATHLEN dependency from gcc/tlink.c Samuel Thibault
2007-08-01  1:39 ` Ian Lance Taylor
2007-08-01 21:03   ` Samuel Thibault
2007-08-04 21:20     ` Samuel Thibault
2007-08-08 14:01     ` Ian Lance Taylor
2007-08-08 14:13       ` Samuel Thibault
2007-08-08 14:25         ` Ian Lance Taylor
2007-08-13 20:57           ` Samuel Thibault

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).