Subversion Repositories Shiroi

Rev

Rev 32 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
8 nishi 1
/* $Id: char.c 33 2024-09-01 09:24:55Z nishi $ */
2
 
3
#include "char.h"
4
 
5
char toupper(char c){
6
	if('a' <= c && c <= 'z'){
7
		return c - 'a' + 'A';
8
	}
9
	return c;
10
}
11
 
12
int strlen(const char* str){
13
	int i;
14
	for(i = 0; str[i] != 0; i++);
15
	return i;
16
}
29 nishi 17
 
18
char strequ(const char* a, const char* b){
19
	if(strlen(a) != strlen(b)) return 0;
20
	int i;
21
	for(i = 0; a[i] != 0; i++){
22
		if(a[i] != b[i]) return 0;
23
	}
24
	return 1;
25
}
26
 
32 nishi 27
int strnum(const char* str){
28
	int i = 0;
29
	int num = 0;
33 nishi 30
	for(i = 0; str[i] != 0; i++){
32 nishi 31
		num = num * 10;
32
		num += str[i] - '0';
33
	}
34
	return num;
35
}
36
 
29 nishi 37
char strcaseequ(const char* a, const char* b){
38
	if(strlen(a) != strlen(b)) return 0;
39
	int i;
40
	for(i = 0; a[i] != 0; i++){
41
		if(toupper(a[i]) != toupper(b[i])) return 0;
42
	}
43
	return 1;
44
}