% January 2012 %
% %
% %
-% Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
% end of the line. You can escape a comment '#', using quotes or backlsashes
% just as you can in a shell.
%
+% The parser will accept both newlines, returns, or return-newlines to mark
+% the EOL. Though this is technically breaking (or perhaps adding to) the
+% 'BASH' syntax that is being followed.
+%
%
% UNIX script Launcher...
%
-% Th euse of '#' comments allow normal UNIX 'scripting' to be used to call on
+% The use of '#' comments allow normal UNIX 'scripting' to be used to call on
% the "magick" command to parse the tokens from a file
%
% #!/path/to/command/magick -script
% #!/usr/bin/env magick-script
%
%
-% Shell script launsher...
+% Shell script launcher...
%
% As a special case a ':' at the start of a line is also treated as a comment
% This allows a magick script to ignore a line that can be parsed by the shell
% script 'launcher' to be used for magick scripts.
%
% #!/bin/sh
+% :; exec magick -script "$0" "$@"; exit 10
% #
-% : echo "This part is run in the shell, but ignored by Magick"
-% : exec magick -script "$0" "$@"; exit 10
+% # The rest of the file is magick script
+% -read label:"This is a Magick Script!"
+% -write show: -exit
+%
+% Or with some shell pre/post processing...
+%
+% #!/bin/sh
+% :; echo "This part is run in the shell, but ignored by Magick"
+% :; magick -script "$0" "$@"
+% :; echo "This is run after the "magick" script is finished!"
+% :; exit 10
% #
% # The rest of the file is magick script
% -read label:"This is a Magick Script!"
%
% DOS script launcher...
%
-% Similarly for DOS, any '@' at the start of the line (outside of quotes)
-% will also be treated as comment. To allow the same DOS script launcher
-% code
+% Similarly any '@' at the start of the line (outside of quotes) will also be
+% treated as comment. This allow you to create a DOS script launcher, to
+% allow a ".bat" DOS scripts to run as "magick" scripts instead.
%
% @echo This line is DOS executed but ignored by Magick
% @magick -script %~dpnx0 %*
+% @echo This line is processed after the Magick script is finished
% @GOTO :EOF
% #
% # The rest of the file is magick script
% -read label:"This is a Magick Script!"
% -write show: -exit
%
+% But this can also be used as a shell script launcher as well!
+% Though is more restrictive and less free-form than using ':'.
+%
+% #!/bin/sh
+% @() { exec magick -script "$@"; }
+% @ "$0" "$@"; exit
+% #
+% # The rest of the file is magick script
+% -read label:"This is a Magick Script!"
+% -write show: -exit
+%
+% Or even like this...
+%
+% #!/bin/sh
+% @() { }
+% @; exec magick -script "$0" "$@"; exit
+% #
+% # The rest of the file is magick script
+% -read label:"This is a Magick Script!"
+% -write show: -exit
+%
*/
\f
/*
% o filename the filename to open ("-" means stdin)
%
*/
-WandExport ScriptTokenInfo *AcquireScriptTokenInfo(char *filename)
+WandExport ScriptTokenInfo *AcquireScriptTokenInfo(const char *filename)
{
ScriptTokenInfo
*token_info;
offset;
/* EOF - no more tokens! */
+ if (token_info == (ScriptTokenInfo *) NULL)
+ return(MagickFalse);
if (token_info->status != TokenStatusOK)
{
token_info->token[0]='\0';
return(MagickFalse);
}
-
state=IN_WHITE;
quote='\0';
offset=0;
+DisableMSCWarning(4127)
while(1)
+RestoreMSCWarning
{
/* get character */
GetChar(c);
if ( ( c == '#' ) ||
( token_info->curr_column==1 && (c == ':' || c == '@' ) ) )
state=IN_COMMENT;
- /* whitespace token seperator character */
+ /* whitespace token separator character */
if (strchr(" \n\r\t",c) != (char *)NULL) {
switch (state) {
case IN_TOKEN: