From e7aeb7a4c8f8b8eedc990308a9cd6bdb17a55b38 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Tue, 3 Aug 2004 00:02:48 +0000 Subject: [PATCH] A better fix for the VC 2k max literal string limit (also affects vc7) --- win32/build/confutils.js | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/win32/build/confutils.js b/win32/build/confutils.js index cb529181ddc..e6b6a23c79b 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -// $Id: confutils.js,v 1.44 2004-08-02 18:48:49 fmk Exp $ +// $Id: confutils.js,v 1.45 2004-08-03 00:02:48 wez Exp $ var STDOUT = WScript.StdOut; var STDERR = WScript.StdErr; @@ -256,9 +256,7 @@ function conf_process_args() args = WScript.Arguments; for (i = 0; i < args.length; i++) { arg = args(i); - if (nice.length + arg.length < 2045) { // The max string length for CONFIGURE_COMMAND is 2048 in VC6 - nice += ' "' + arg + '"'; - } + nice += ' "' + arg + '"'; if (arg == "--help") { configure_help_mode = true; break; @@ -1212,8 +1210,9 @@ function generate_config_h() outfile.Write(indata); var keys = (new VBArray(configure_hdr.Keys())).toArray(); - var i; + var i, j; var item; + var pieces, stuff_to_crack, chunk; outfile.WriteBlankLines(1); outfile.WriteLine("/* values determined by configure.js */"); @@ -1222,7 +1221,29 @@ function generate_config_h() item = configure_hdr.Item(keys[i]); outfile.WriteBlankLines(1); outfile.WriteLine("/* " + item[1] + " */"); - outfile.WriteLine("#define " + keys[i] + " " + item[0]); + pieces = item[0]; + + if (typeof(pieces) == "string" && pieces.charCodeAt(0) == 34) { + /* quoted string have a maximal length of 2k under vc. + * solution is to crack them and let the compiler concat + * them implicitly */ + stuff_to_crack = pieces; + pieces = ""; + + while (stuff_to_crack.length) { + j = 65; + while (stuff_to_crack.charCodeAt(j) != 32 && j < stuff_to_crack.length) + j++; + + chunk = stuff_to_crack.substr(0, j); + pieces += chunk; + stuff_to_crack = stuff_to_crack.substr(chunk.length); + if (stuff_to_crack.length) + pieces += '" "'; + } + } + + outfile.WriteLine("#define " + keys[i] + " " + pieces); } outfile.Close();