From: anthony Date: Fri, 30 Mar 2012 04:43:45 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~5938 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ff521019679f031cd61517f41dcae654dcbc2633;p=imagemagick --- diff --git a/MagickWand/script-token-test-data.txt b/MagickWand/script-token-test-data.txt deleted file mode 100644 index 4769b317e..000000000 --- a/MagickWand/script-token-test-data.txt +++ /dev/null @@ -1,42 +0,0 @@ -# -# Comments should be ignored -# --option key # end of line comment -+reset imbedded#hash # <- not a comment, thought this is - -This\ is' a 'single" token" - -And\\\ \''even '\'\""more \""complex - -"Backslash chars \n are returned as is" -'regardless \n of quoting' - -'Single quote escapes' -\' "'" - -"Double quote escapes" -\" '"' "\"" - -Back\ slash\ escapes -\\ '\' "\\" # NOTE that backslash in single quotes are literial! - -'Space Character Escapes' -\ ' ' " " - -'Empty Tokens, using quotes' -'' "" - -"Unicode charcaters are handled" -"° ' ² ³ ` ´" -"µ ¶ ⨀ ⨁ ⨂" -测试用的汉字 - -Lines__\ -__Continuation - -'quoted_newlines__ -__are_part_of_token' - -"Last Token before EOF" - - diff --git a/MagickWand/script-token-test.c b/MagickWand/script-token-test.c deleted file mode 100644 index f1222c2d5..000000000 --- a/MagickWand/script-token-test.c +++ /dev/null @@ -1,139 +0,0 @@ -/* -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% % -% % -% SSS CCC RRRR III PPPP TTTTT TTTTT OOO K K EEEE N N % -% S C R R I P P T T O O K K E NN N % -% SSS C RRRR I PPPP T T O O KK EEE N N N % -% S C R R I P T T O O K K E N NN % -% SSSS CCC R RR III P T T OOO K K EEEE N N % -% % -% TTTTT EEEEE SSSSS TTTTT % -% T E SS T % -% T EEE SSS T % -% T E SS T % -% T EEEEE SSSSS T % -% % -% Perform "Magick" on Images via the Command Line Interface % -% % -% Dragon Computing % -% Anthony Thyssen % -% January 2012 % -% % -% % -% Copyright 1999-2012 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 % -% obtain a copy of the License at % -% % -% http://www.imagemagick.org/script/license.php % -% % -% Unless required by applicable law or agreed to in writing, software % -% distributed under the License is distributed on an "AS IS" BASIS, % -% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % -% See the License for the specific language governing permissions and % -% limitations under the License. % -% % -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% -% Test the raw tokanization of the ScriptToken Subroutines -% -% This actually uses very little of the magic core functions -% and in fact creates a completely stand-alone program by substituting -% required MagickCore with direct system equivelents. -% -% Build -% cc script-token-test.c -o script-token-test -% -% For testing see script-token-test.sh -% -*/ - -/* System Replacement for MagickWand includes */ -#include -#include -#include -#include -#include - -#define MaxTextExtent 4096 -#define MagickFalse 0 -#define MagickTrue 1 -#define MagickBooleanType int - -#define AcquireMagickMemory(s) malloc(s) -#define RelinquishMagickMemory(p) (free(p),NULL) -#define ResizeMagickMemory(p,s) realloc(p,s) -#define ResetMagickMemory(p,b,s) memset(p,b,s) -#define StringToLong(s) strtol(s,(char **) NULL,10) -#define LocaleCompare(p,q) strcasecmp(p,q) -#define LocaleNCompare(p,q,l) strncasecmp(p,q,l) -#define WandSignature 0xabacadabUL -#define WandExport - -/* Include the actual code for ScriptToken functions */ -#define SCRIPT_TOKEN_TESTING 1 /* Prevent MagickWand Includes */ -#include "script-token.h" -#include "script-token.c" - -/* Test program to report what tokens it finds in given input file/stream */ - -int main(int argc, char *argv[]) -{ - ScriptTokenInfo - *token_info; - - token_info = AcquireScriptTokenInfo( (argc>1) ? argv[1] : "-" ); - if (token_info == (ScriptTokenInfo *) NULL) { - printf("Script Open Failure : %s\n", strerror(errno)); - return(1); - } - - while (1) { - if( GetScriptToken(token_info) == MagickFalse ) - break; - - if( strlen(token_info->token) > INITAL_TOKEN_LENGTH-1 ) { - token_info->token[INITAL_TOKEN_LENGTH-4] = '.'; - token_info->token[INITAL_TOKEN_LENGTH-3] = '.'; - token_info->token[INITAL_TOKEN_LENGTH-2] = '.'; - token_info->token[INITAL_TOKEN_LENGTH-1] = '\0'; - } - printf("l=%d, c=%d, stat=%d, len=%d, token=\"%s\"\n", - token_info->token_line, token_info->token_column, - token_info->status, token_info->length, token_info->token); - } - - switch( token_info->status ) { - case TokenStatusOK: - break; - case TokenStatusEOF: - printf("EOF Found\n"); - break; - case TokenStatusBadQuotes: - /* Ensure last token has a sane length for error report */ - if( strlen(token_info->token) > INITAL_TOKEN_LENGTH-1 ) { - token_info->token[INITAL_TOKEN_LENGTH-4] = '.'; - token_info->token[INITAL_TOKEN_LENGTH-3] = '.'; - token_info->token[INITAL_TOKEN_LENGTH-2] = '.'; - token_info->token[INITAL_TOKEN_LENGTH-1] = '\0'; - } - printf("Bad Quotes l=%d, c=%d token=\"%s\"\n", - token_info->token_line,token_info->token_column, token_info->token); - break; - case TokenStatusMemoryFailed: /* token is invalid */ - printf("Out of Memory l=%d, c=%d\n", - token_info->token_line,token_info->token_column); - break; - case TokenStatusBinary: /* token is invalid */ - printf("Binary Char at l=%d, c=%d\n", - token_info->curr_line,token_info->curr_column); - break; - } - - /* Clean up */ - token_info = DestroyScriptTokenInfo(token_info); - - return(0); -} diff --git a/MagickWand/script-token-test.sh b/MagickWand/script-token-test.sh deleted file mode 100755 index b80f1ad68..000000000 --- a/MagickWand/script-token-test.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# -# -# Basic testing of ScriptToken parser. -# -./script-token-test script-token-test-data.txt -echo "" - - - -echo -n "\"Next token bad quotes\" \"unfinished quotes ->" |\ - ./script-token-test -echo "" - - - -perl -e 'print "\"Binary input follows\"\n", "abc\006xyz\n"' |\ - ./script-token-test -echo "" - - - -( echo '"Very BIG Token Tests"' - dd if=/dev/zero bs=80 count=1 2>/dev/null | tr '\0' 'a'; echo "" - dd if=/dev/zero bs=500 count=1 2>/dev/null | tr '\0' 'b'; echo "" - dd if=/dev/zero bs=4000 count=1 2>/dev/null | tr '\0' 'c'; echo "" - dd if=/dev/zero bs=5000 count=1 2>/dev/null | tr '\0' 'd'; echo "" - dd if=/dev/zero bs=10k count=1 2>/dev/null | tr '\0' 'e'; echo "" - dd if=/dev/zero bs=13k count=1 2>/dev/null | tr '\0' 'f'; echo "" - dd if=/dev/zero bs=8k count=1024 2>/dev/null | tr '\0' 'e'; echo "" - echo '"and all is well!"' -) | ./script-token-test -echo "" -