Sha256: 3b04646a852c54eee4ce0584ba6dec69c92240eeee61c090773f826520b2284d

Contents?: true

Size: 1.6 KB

Versions: 230

Compression:

Stored size: 1.6 KB

Contents

/*
Shiltiumcomp -- the first Shiltolang compiler

Copyright (C) 2010 Gregory Cohen <gregorycohenvideos@gmail.com>

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "../global_headers/headers.h"

bool strequal(const char* cr string1, const char* cr string2) {
	u i;
	
	assert_comparison(string1, !=, NULL, const char*, void*);
	assert_comparison(string2, !=, NULL, const char*, void*);
	
	for (i = 0 ;; ++i) {
		if (!ARRAY_INDEX(string1, i)) {
			return !ARRAY_INDEX(string2, i);
		}
		if (!ARRAY_INDEX(string2, i)) {
			return !ARRAY_INDEX(string1, i);
		}
		if (ARRAY_INDEX(string1, i) != ARRAY_INDEX(string2, i)) return false;
	}
}

/* str-num-equal, not str-not-equal */
bool strnequal(const char* cr string1, const char* cr string2, const u length1, const u length2) {
	u i;
	
	assert_comparison(string1, !=, NULL, const char*, void*);
	assert_comparison(string2, !=, NULL, const char*, void*);
	
	if (length1 != length2) return false;
	
	i = length1;
	while (i--) {
		if (ARRAY_INDEX(string1, i) != ARRAY_INDEX(string2, i)) return false;
	}
	
	return true;
}

Version data entries

230 entries across 46 versions & 6 rubygems

Version Path
aliens-1.0.72 ./other/old_compiler/shiltiumcomp/portable/string_comparison.c
aliens-1.0.72 ./other/old_compiler/shiltiumcomp58/portable/string_comparison.c
aliens-1.0.72 ./other/old_compiler/shiltiumcomp59/portable/string_comparison.c
aliens-1.0.72 ./other/old_compiler/shiltiumcomp76/portable/string_comparison.c
aliens-1.0.72 ./other/old_compiler/shiltiumcomp78/portable/string_comparison.c
freespeech-1.0.72 ./other/old_compiler/shiltiumcomp/portable/string_comparison.c
freespeech-1.0.72 ./other/old_compiler/shiltiumcomp58/portable/string_comparison.c
freespeech-1.0.72 ./other/old_compiler/shiltiumcomp59/portable/string_comparison.c
freespeech-1.0.72 ./other/old_compiler/shiltiumcomp76/portable/string_comparison.c
freespeech-1.0.72 ./other/old_compiler/shiltiumcomp78/portable/string_comparison.c
freespeech-1.0.71 ./other/old_compiler/shiltiumcomp78/portable/string_comparison.c
freespeech-1.0.71 ./other/old_compiler/shiltiumcomp76/portable/string_comparison.c
freespeech-1.0.71 ./other/old_compiler/shiltiumcomp59/portable/string_comparison.c
freespeech-1.0.71 ./other/old_compiler/shiltiumcomp58/portable/string_comparison.c
freespeech-1.0.71 ./other/old_compiler/shiltiumcomp/portable/string_comparison.c
elonmusk-1.0.71 ./other/old_compiler/shiltiumcomp/portable/string_comparison.c
elonmusk-1.0.71 ./other/old_compiler/shiltiumcomp58/portable/string_comparison.c
elonmusk-1.0.71 ./other/old_compiler/shiltiumcomp59/portable/string_comparison.c
elonmusk-1.0.71 ./other/old_compiler/shiltiumcomp76/portable/string_comparison.c
elonmusk-1.0.71 ./other/old_compiler/shiltiumcomp78/portable/string_comparison.c