www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Assertion failure: '0' on line 872 in file 'constfold.c'

reply long <changlon gmail.com> writes:
void main(){}

char[] ctfe_lower(char[] s){
	char[] res	;
	foreach(int i, c;s){
		if( c >= 'A' && c <='Z' ){
			res	~= c + 32 ;
		}else{
			res	~= c;
		}
	}
	return res;
}

char[] ctfe_remove(char[] _if, char[] remove){
	_if		= ctfe_lower(_if.dup);
	char[] limit	= ctfe_lower(remove.dup);
	int len	= limit.length;
	char[] _if2	= null;
	foreach(int i, c; _if){
		if( _if.length - i > len ){
			if( _if[i..i+len] == limit ){
				if( _if[i+len] is ' ' ){
					_if2	= _if[0..i].dup;
					break;
				}
			}
		}
	}
	if( _if2 is null ){
		_if2	= _if.dup;
	}
	return _if2;
}

pragma(msg, ctfe_remove("1234 5", "34") );
Apr 20 2009
parent "Denis Koroskin" <2korden gmail.com> writes:
On Tue, 21 Apr 2009 09:33:19 +0400, long <changlon gmail.com> wrote:

 void main(){}

 char[] ctfe_lower(char[] s){
 	char[] res	;
 	foreach(int i, c;s){
 		if( c >= 'A' && c <='Z' ){
 			res	~= c + 32 ;
 		}else{
 			res	~= c;
 		}
 	}
 	return res;
 }

 char[] ctfe_remove(char[] _if, char[] remove){
 	_if		= ctfe_lower(_if.dup);
 	char[] limit	= ctfe_lower(remove.dup);
 	int len	= limit.length;
 	char[] _if2	= null;
 	foreach(int i, c; _if){
 		if( _if.length - i > len ){
 			if( _if[i..i+len] == limit ){
 				if( _if[i+len] is ' ' ){
 					_if2	= _if[0..i].dup;
 					break;
 				}
 			}
 		}
 	}
 	if( _if2 is null ){
 		_if2	= _if.dup;
 	}
 	return _if2;
 }

 pragma(msg, ctfe_remove("1234 5", "34") );

Bug reports should be posted in bugzilla, this newsgroup is just for easy tracking of new bug-reports. At least, it works that way only, and posting here doesn't introduce new bugzilla entries automatically. http://d.puremagic.com/issues/
Apr 21 2009