all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Supporting parameters that include the = character in configure.bat
@ 2011-04-10  7:51 Ben Key
  2011-04-10  8:14 ` Eli Zaretskii
  0 siblings, 1 reply; 14+ messages in thread
From: Ben Key @ 2011-04-10  7:51 UTC (permalink / raw)
  To: Emacs-devel

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

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.

<batch_file>
@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%
</batch_file>

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.

<batch_file>
@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%
</batch_file>

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?

[-- Attachment #2: Type: text/html, Size: 2988 bytes --]

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

end of thread, other threads:[~2011-04-15  9:45 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-10  7:51 Supporting parameters that include the = character in configure.bat Ben Key
2011-04-10  8:14 ` Eli Zaretskii
2011-04-10  8:46   ` Ben Key
2011-04-10  9:49     ` Eli Zaretskii
     [not found]       ` <BANLkTi=QekwZQLVSoMFE0sTO+RRGAGackQ@mail.gmail.com>
2011-04-10 16:36         ` Eli Zaretskii
2011-04-12  0:17           ` Ben Key
2011-04-12  2:41             ` Ben Key
2011-04-12  5:08               ` Eli Zaretskii
2011-04-13 23:17                 ` Ben Key
2011-04-14  5:11                   ` Eli Zaretskii
2011-04-14 10:38                     ` Juanma Barranquero
2011-04-15  0:56                       ` Ben Key
2011-04-15  9:45                         ` Eli Zaretskii
2011-04-12  2:48             ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.