[YukiWiki] [[hrefStop()]]

[ トップ | 一覧 | 編集 | 差分 | 単語検索 | 最終更新 | ]

[[hrefStop()]]とは何か


 /* 
	hrefStop

	文字 x が href の value として許容されるか判定する。
	対象文字列に対し連続して呼ばれる低レベル関数。

	戻り値: 1..許容 / 0..非許容
 */ 

#ifdef oldcode

 int	hrefStop(char x)
 {
	if('A' <= x && x <= 'Z')	return	0	;
	if('a' <= x && x <= 'z')	return	0	;
	if('0' <= x && x <= '9')	return	0	;
	if(x == '#')	return	0	;
	if(x == '/')	return	0	;
	if(x == '~')	return	0	;
	if(x == '_')	return	0	;
	if(x == '.')	return	0	;
	if(x == ',')	return	0	;
	if(x == '$')	return	0	;
	if(x == '%')	return	0	;
	if(x == '&')	return	0	;
	if(x == '@')	return	0	;
	if(x == '?')	return	0	;
	if(x == '=')	return	0	;
	if(x == '-')	return	0	;
	if(x == '+')	return	0	;
	if(x == '*')	return	0	;
	if(x == ';')	return	0	;
	if(x == ':')	return	0	;
	if(x == '!')	return	0	;
	if(x == '^')	return	0	;
	if(x == '`')	return	0	;
	if(x == '|')	return	0	;
	if(x == '[')	return	0	;
	if(x == ']')	return	0	;
	if(x == '{')	return	0	;
	if(x == '}')	return	0	;
	if(x == '\\')	return	0	;
	return	1	;
 }

 #else /* !oldcode */


改良版hrefStop

 const char s_pHrefTable[] = { 
 1,0,1,0,0,0,0,0,1,1,0,0,0,0,0,0, 
 0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0, 
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 
 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 
 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}; 

 #define hrefStop(x) (isgraph(x) ? s_pHrefTable[(x)-0x20] : 1) 

 #endif /* !oldcode */


TODO

isgraph()もテーブルに押し込めろ


改良版hrefStop2

 #define hrefStop(x) (s_pHrefTable[x])

 const char s_pHrefTable[] = { 
 	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,	//0 - 15
 	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,	//16 - 31
 	1,0,1,0,0,0,0,0,1,1,0,0,0,0,0,0,	//32 - 47
 	0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,	//48 - 63
 	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,	//64 - 79
 	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,	//80 - 95
 	1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 	//96 - 111
 	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 	//112 - 127
 	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,	//128 - 143
 	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,	//144 - 159
 	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,	//160 - 175
 	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,	//176 - 191
 	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,	//192 - 207
 	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,	//208 - 223
 	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,	//224 - 239
 	1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 	//240 - 255
 };

YukiWiki 1.6.2 Copyright (C) 2000,2001 by Hiroshi Yuki.
Modified by aki.