From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ben Key Newsgroups: gmane.emacs.devel Subject: Supporting parameters that include the = character in configure.bat Date: Sun, 10 Apr 2011 02:51:34 -0500 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=000325557dae8b139f04a08bbb31 X-Trace: dough.gmane.org 1302421935 12755 80.91.229.12 (10 Apr 2011 07:52:15 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 10 Apr 2011 07:52:15 +0000 (UTC) To: Emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Apr 10 09:52:10 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q8pRJ-0002n2-5P for ged-emacs-devel@m.gmane.org; Sun, 10 Apr 2011 09:52:09 +0200 Original-Received: from localhost ([127.0.0.1]:50068 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q8pRH-0005eb-NY for ged-emacs-devel@m.gmane.org; Sun, 10 Apr 2011 03:52:07 -0400 Original-Received: from [140.186.70.92] (port=47668 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q8pR8-0005dm-MB for Emacs-devel@gnu.org; Sun, 10 Apr 2011 03:51:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q8pR6-00088t-Um for Emacs-devel@gnu.org; Sun, 10 Apr 2011 03:51:58 -0400 Original-Received: from mail-bw0-f41.google.com ([209.85.214.41]:61111) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q8pR6-00088b-Jy for Emacs-devel@gnu.org; Sun, 10 Apr 2011 03:51:56 -0400 Original-Received: by bwz17 with SMTP id 17so4377469bwz.0 for ; Sun, 10 Apr 2011 00:51:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:from:date:message-id:subject:to :content-type; bh=8hhAFhxW2eO6qE2eENDU725XI+9k/amCpGeMsKQ/Nr8=; b=V7hRPsqEDLyVS2s45nDzbtarV/QWg8hqGvTFwNLyJYZ6PNey1jet2DYbcUw+HiXHfR W8yNNbe0T4FMnI+9RPJJ4724q3S15RKOk/zffgaJOhIi4yDcBBEhOnPAE04AC6Luaje8 CCQw7UPjK+841CdlakjOe5OzXx6in85aU37ME= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=dDwbplr7pR/qpK6yniBFKVG9+PBTxErqqDhTR6SiirhIwJFtyGL2K3L/4jsE+uVC3Q UCZRLQ5/HE8CEU6R4lOgNq7MWy175Ni0ZJ1WnH8YnJjWqTk3i6hBNj7SKMkee4a/HY4B NgMTSTbCeSAQD7qJKnT8qwmV372oXCLS0E2oU= Original-Received: by 10.204.10.21 with SMTP id n21mr3660586bkn.77.1302421914194; Sun, 10 Apr 2011 00:51:54 -0700 (PDT) Original-Received: by 10.204.118.203 with HTTP; Sun, 10 Apr 2011 00:51:34 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.214.41 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:138346 Archived-At: --000325557dae8b139f04a08bbb31 Content-Type: text/plain; charset=ISO-8859-1 Hello, I have seen several mentions on this list of the desire to make configure.bat support parameters that include the = character. The --cflags parameter was mentioned specifically. For example Eli Zaretskii wanted to be able to call configure.bat with --cflags -DSITELOAD_PURESIZE_EXTRA=100000. There is a way to do this on Windows operating systems based on Windows NT. The following batch file demonstrates how this might be accomplished. @echo off set sep1= :again if "%1" == "--cflags" goto usercflags if "%1" == "" goto checkutils :usercflags shift set usercflags=%usercflags%%sep1%%~1 set sep1= %nothing% shift goto again :checkutils echo usercflags=%usercflags% The key here is the usage of the ~ character between the % and the 1. This essentially causes " characters around the parameter to be removed. Thus when this batch file is called as follows test.bat --cflags "-DSITELOAD_PURESIZE_EXTRA=100000" --cflags "-DTEST=1" the output is as follows usercflags=-DSITELOAD_PURESIZE_EXTRA=100000 -DTEST=1 As long as the parameter is surrounded by " characters, the = character will not be treated as a separator. The major drawback of this is that it will not work on Windows 9x because command.com does not support this functionality. I see two possible solutions to this problem. The first is to have two versions of configure.bat, a main version that uses this trick and another version that is backwards compatible with Windows 9x. Another possible solution is to somehow have configure.bat test to see if this functionality is supported and use it if it is available and otherwise not use the functionality. The following batch file shows how this might be accomplished. @echo off set sep1= :again if "%1" == "--cflags" goto usercflags if "%1" == "" goto checkutils :usercflags if "%OS%" == "Windows_NT" goto ucflagnt goto ucflag9x :ucflagnt shift set usercflags=%usercflags%%sep1%%~1 set sep1= %nothing% shift goto again :ucflag9x shift set usercflags=%usercflags%%sep1%%1 set sep1= %nothing% shift goto again :checkutils echo usercflags=%usercflags% The drawback of this approach is that it would make an already complex batch file even more complex. It does however make it possible to support a much needed feature, at least on Windows operating systems based on Windows NT, without the maintenance headache that using two batch files would introduce. What do you all think about this approach? --000325557dae8b139f04a08bbb31 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hello,

I have seen several mentions on this list of= the desire to make configure.bat support parameters that include the =3D c= haracter.=A0 The --cflags parameter was mentioned specifically.=A0 For exam= ple Eli Zaretskii wanted to be able to call configure.bat with --cflags -DS= ITELOAD_PURESIZE_EXTRA=3D100000.

There is a way to do this on Windows operating systems based on Windows= NT.=A0 The following batch file demonstrates how this might be accomplishe= d.

<batch_file>
@echo off

set sep1=3D
:again

if "%1" =3D=3D "--cflags" goto usercflags
if "%= 1" =3D=3D "" goto checkutils

:usercflags
shift
= set usercflags=3D%usercflags%%sep1%%~1
set sep1=3D %nothing%
shiftgoto again

:checkutils

echo usercflags=3D%usercflags%
</batch_file>= ;

The key here is the usage of the ~ character between the % and the= 1.=A0 This essentially causes " characters around the parameter to be= removed.=A0 Thus when this batch file is called as follows
=A0 test.bat --cflags "-DSITELOAD_PURESIZE_EXTRA=3D100000" --cfla= gs "-DTEST=3D1"
the output is as follows
=A0 usercflags=3D-= DSITELOAD_PURESIZE_EXTRA=3D100000 -DTEST=3D1

As long as the paramete= r is surrounded by " characters, the =3D character will not be treated= as a separator.

The major drawback of this is that it will not work on Windows 9x becau= se command.com does not support this fun= ctionality.=A0 I see two possible solutions to this problem.=A0 The first i= s to have two versions of configure.bat, a main version that uses this tric= k and another version that is backwards compatible with Windows 9x.=A0 Anot= her possible solution is to somehow have configure.bat test to see if this = functionality is supported and use it if it is available and otherwise not = use the functionality.=A0 The following batch file shows how this might be = accomplished.

<batch_file>
@echo off

set sep1=3D
:again

if = "%1" =3D=3D "--cflags" goto usercflags
if "%1&q= uot; =3D=3D "" goto checkutils

:usercflags

if "= ;%OS%" =3D=3D "Windows_NT" goto ucflagnt
goto ucflag9x

:ucflagnt
shift
set usercflags=3D%usercflags%%se= p1%%~1
set sep1=3D %nothing%
shift
goto again

:ucflag9x
= shift
set usercflags=3D%usercflags%%sep1%%1
set sep1=3D %nothing%
= shift
goto again

:checkutils

echo usercflags=3D%usercflags%
<= /batch_file>

The drawback of this approach is that it would make = an already complex batch file even more complex.=A0 It does however make it= possible to support a much needed feature, at least on Windows operating s= ystems based on Windows NT, without the maintenance headache that using two= batch files would introduce.


What do you all think about this approach?

--000325557dae8b139f04a08bbb31--