public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] drop MAXPATHLEN dependency from gcc/tlink.c
Date: Tue, 24 Jul 2007 21:19:00 -0000	[thread overview]
Message-ID: <20070724203941.GE3700@interface.famille.thibault.fr> (raw)

[-- 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

             reply	other threads:[~2007-07-24 20:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-24 21:19 Samuel Thibault [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070724203941.GE3700@interface.famille.thibault.fr \
    --to=samuel.thibault@ens-lyon.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).