-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathqcommon.c
More file actions
62 lines (50 loc) · 975 Bytes
/
qcommon.c
File metadata and controls
62 lines (50 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "qcommon.h"
#include "main.h"
int Q_stricmpn( const char *s1, const char *s2, int n )
{
int c1, c2;
if ( s1 == NULL ) {
if ( s2 == NULL )
return 0;
else
return -1;
}
else if ( s2==NULL )
return 1;
do {
c1 = *s1++;
c2 = *s2++;
if (!n--) {
return 0; // strings are equal until end point
}
if (c1 != c2) {
if (c1 >= 'a' && c1 <= 'z') {
c1 -= ('a' - 'A');
}
if (c2 >= 'a' && c2 <= 'z') {
c2 -= ('a' - 'A');
}
if (c1 != c2) {
return c1 < c2 ? -1 : 1;
}
}
} while (c1);
return 0; // strings are equal
}
int Q_stricmp( const char *s1, const char *s2 )
{
return (s1 && s2) ? Q_stricmpn (s1, s2, 99999) : -1;
}
char* Q_Strcpy( const char *str )
{
char *newstr = malloc( strlen( str ) + 1 );
if( newstr )
{
strcpy( newstr, str );
}
else
{
Plugin_PrintError( "Q_Strcpy: failed to alloc memory!" );
}
return newstr;
}