-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathpceth2_str.c
More file actions
58 lines (49 loc) · 966 Bytes
/
pceth2_str.c
File metadata and controls
58 lines (49 loc) · 966 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
/*
* pceth2 - 文字列処理関連
*
* (c)2005 てとら★ぽっと
*
* 2005/07/23 pceth2_sys.c, common.hから分離
*/
#include <string.h>
#include <piece.h>
#include "common.h"
#include "pceth2_str.h"
/*
* 2バイト文字かどうか
* *s スクリプトデータ
* return TRUE/FALSE
*/
#define isKanji(x) (((x) >= 0x81 && (x) <= 0x9f) || ((x) >= 0xe0 && (x) <= 0xfc))
BOOL pceth2_isKanji(SCRIPT_DATA *s)
{
return(isKanji(*(s->data + s->p)));
}
/*
* 数値を取得
* *s スクリプトデータ
* return 取得した数値
*/
#define isDigit(x) ((x) >= '0' && (x) <= '9')
int pceth2_getNum(SCRIPT_DATA *s)
{
int ret = 0;
for(; isDigit(*(s->data + s->p)); s->p++) {
ret *= 10;
ret += *(s->data + s->p) - '0';
}
return ret;
}
/*
* スクリプトデータから文字列をコピー
*
* *dst コピー先のポインタ
* *s スクリプトデータ
* len コピー文字列長
*/
void pceth2_strcpy(char *dst, SCRIPT_DATA *s, DWORD len)
{
strncpy(dst, s->data + s->p, len);
*(dst + len) = '\0';
s->p += len;
}