-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappend_data.hsp
99 lines (90 loc) · 2.52 KB
/
append_data.hsp
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef append_data_hsp_included
#define append_data_hsp_included
#include "hsptest_result_format.as"
#module
#define SUCCESS 1
#define FAILURE 0
/*
引数が単語に使用される文字コードかどうかを判定する
引数
ch: 文字コード
返り値
文字コードが単語に使用されるものの場合true
*/
#defcfunc is_name_alphabet int ch
return ('A' <= ch && ch <= 'Z') || ('a' <= ch && ch <= 'z') || ('0' <= ch && ch <= '9') || ch == '_'
/*
引数が空白文字コードかどうかを判定する
引数
ch: 文字コード
返り値
文字コードが空白文字の場合true
*/
#defcfunc is_space int ch
return ch == ' ' || ch == '\t'
/*
引数の行文字列がHSP3におけるマルチラインコードかどうかを判定する
引数
line_str: HSP3スクリプトの1行コード文字列
返り値
コードがマルチラインコードの場合true
*/
#defcfunc is_multi_line str line_str
line_str_buf = line_str
result = 0
repeat strlen(line_str_buf)
ch = peek(line_str_buf, strlen(line_str_buf) - 1 - cnt)
if is_space(ch) : continue
if ch == '\\' {
result = 1
break
}
break
loop
return result
/*
スクリプトに状態取得用プログラムを挿入したコピーを作成する
引数
src_file_path: コピー元スクリプトへのパス
dest_file_path: コピー先スクリプトへのパス
*/
#deffunc copy_with_edit str src_file_path, str dest_file_path
notesel buf
noteload src_file_path
file_line_num = notemax
reading_index = 0
ignore_multiline_str = 0
ignore_multiline_inst = 0
repeat
notesel buf
; if cnt >= notemax : break
if cnt > file_line_num : break
noteget l, reading_index
reading_index++
if ignore_multiline_str == 0 && ignore_multiline_inst == 0{
if reading_index - 1 >= notemax {
p = -1
} else {
p = reading_index - 1
}
now_line_num = cnt + 1
noteadd "__errfile@(sublev) = __file__ : __errline@(sublev) = " + now_line_num + " : __sublev@ = sublev", p
reading_index++
}
ignore_multiline_inst = 0
// マルチライン文字列には挿入しない
if ignore_multiline_str == 0 && instr(l, 0, "{\"") != -1 && instr(l, 0, "\"}") == -1 {
ignore_multiline_str = 1
}
if ignore_multiline_str && instr(l, 0, "{\"") == -1 && instr(l, 0, "\"}") != -1 {
ignore_multiline_str = 0
}
if ignore_multiline_str == 0 && is_multi_line(l) {
ignore_multiline_inst = 1
}
loop
notesel buf
notesave dest_file_path
return
#global
#endif