• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythongamewindowsbathyscaphephpguic翻訳omegattwitterframeworktestbtronarduinovb.net計画中(planning stage)directxpreviewerゲームエンジンdom

シェルスクリプト言語xyzshのソースコード。


コミットメタ情報

リビジョンc061bec744f5920dfbb8d7591b2ea8eae1d629a3 (tree)
日時2013-02-02 12:35:58
作者ab25q <ab25cq@gmai...>
コミッターab25q

ログメッセージ

1.3.3

変更サマリ

差分

--- a/CHANGELOG
+++ b/CHANGELOG
@@ -35,6 +35,8 @@
3535 > adfastfa | less
3636 adfastfa is not found
3737
38+ 11. Fixed scan, split, sub, index, rindex with null string argument. There are some odd working.
39+
3840 2013 20th January version 1.3.2
3941
4042 1. Added "strip" and "objinfo" inner command
--- a/src/cmd_str.c
+++ b/src/cmd_str.c
@@ -1356,7 +1356,12 @@ BOOL cmd_scan(sObject* nextin, sObject* nextout, sRunInfo* runinfo)
13561356 }
13571357 }
13581358
1359- p = SFD(nextin).mBuf + region->end[0];
1359+ if(p == SFD(nextin).mBuf + region->end[0]) {
1360+ p = SFD(nextin).mBuf + region->end[0] + 1;
1361+ }
1362+ else {
1363+ p = SFD(nextin).mBuf + region->end[0];
1364+ }
13601365 }
13611366 else {
13621367 p++;
@@ -1669,6 +1674,10 @@ static char* strstr_back(char* p, char* start, char* word, char* sname, int slin
16691674 {
16701675 int n = strlen(word);
16711676
1677+ if(word[0] == 0) {
1678+ return p -1;
1679+ }
1680+
16721681 while(p >= start) {
16731682 BOOL flg = TRUE;
16741683 int i;
@@ -1700,6 +1709,10 @@ static char* strcasestr_back(char* p, char* start, char* word, char* sname, int
17001709 {
17011710 int n = strlen(word);
17021711
1712+ if(word[0] == 0) {
1713+ return p - 1;
1714+ }
1715+
17031716 while(p >= start) {
17041717 BOOL flg = TRUE;
17051718 int i;
@@ -2399,29 +2412,37 @@ BOOL cmd_split(sObject* nextin, sObject* nextout, sRunInfo* runinfo)
23992412
24002413 if(runinfo->mFilter) {
24012414 if(sRunInfo_option(runinfo, "-no-regex")) {
2415+ BOOL ignore_case = sRunInfo_option(runinfo, "-ignore-case");
24022416 char* word;
2417+ int word_len;
24032418
24042419 if(runinfo->mArgsNumRuntime == 1) {
24052420 word = " ";
2421+ word_len = 1;
24062422 }
24072423 else if(runinfo->mArgsNumRuntime >= 2) {
24082424 word = runinfo->mArgsRuntime[1];
2425+ word_len = strlen(word);
24092426 }
24102427
24112428 char* target;
24122429 char* p = target = SFD(nextin).mBuf;
2430+ int target_len = SFD(nextin).mBufLen;
24132431
24142432 int split_count = 0;
24152433
2416- while(1) {
2434+ while(p - target < target_len) {
24172435 char* result;
2418- if(sRunInfo_option(runinfo, "-ignore-case")) {
2436+ if(word[0] == 0) {
2437+ result = p + 1;
2438+ }
2439+ else if(ignore_case) {
24192440 result = strcasestr(p, word);
24202441 }
24212442 else {
24222443 result = strstr(p, word);
24232444 }
2424-
2445+
24252446 if(result == NULL) {
24262447 if(*p) {
24272448 if(!fd_write(nextout, p, strlen(p))) {
@@ -2453,7 +2474,7 @@ BOOL cmd_split(sObject* nextin, sObject* nextout, sRunInfo* runinfo)
24532474 return FALSE;
24542475 }
24552476
2456- p = result + strlen(word);
2477+ p = result + word_len;
24572478 }
24582479 }
24592480
@@ -2484,10 +2505,11 @@ BOOL cmd_split(sObject* nextin, sObject* nextout, sRunInfo* runinfo)
24842505 if(r == ONIG_NORMAL) {
24852506 char* target;
24862507 char* p = target = SFD(nextin).mBuf;
2508+ int target_len = SFD(nextin).mBufLen;
24872509
24882510 int split_count = 0;
24892511
2490- while(1) {
2512+ while(p - target < target_len) {
24912513 OnigRegion* region = onig_region_new();
24922514
24932515 int r2 = onig_search(reg, target
--- a/src/ext/migemo.c
+++ b/src/ext/migemo.c
@@ -65,6 +65,40 @@ static void migemo_final()
6565 hash_delete_on_malloc(gMigemoCache);
6666 }
6767
68+BOOL cmd_migemo_querry(sObject* nextin, sObject* nextout, sRunInfo* runinfo)
69+{
70+ if(runinfo->mArgsNumRuntime == 2) {
71+ char* regex = runinfo->mArgsRuntime[1];
72+
73+ OnigUChar * p = migemo_query(gMigemo, regex);
74+ if(p == NULL) {
75+ err_msg("migemo query failed", runinfo->mSName, runinfo->mSLine, runinfo->mArgs[0]);
76+ migemo_release(gMigemo, (unsigned char*) p);
77+ return FALSE;
78+ }
79+
80+ if(!fd_write(nextout, p, strlen(p))) {
81+ err_msg("signal interrupt", runinfo->mSName, runinfo->mSLine, runinfo->mArgs[0]);
82+ runinfo->mRCode = RCODE_SIGNAL_INTERRUPT;
83+ migemo_release(gMigemo, (unsigned char*) p);
84+ return FALSE;
85+ }
86+
87+ if(!fd_write(nextout, "\n", 1)) {
88+ err_msg("signal interrupt", runinfo->mSName, runinfo->mSLine, runinfo->mArgs[0]);
89+ runinfo->mRCode = RCODE_SIGNAL_INTERRUPT;
90+ migemo_release(gMigemo, (unsigned char*) p);
91+ return FALSE;
92+ }
93+
94+ migemo_release(gMigemo, (unsigned char*) p);
95+
96+ runinfo->mRCode = 0;
97+ }
98+
99+ return TRUE;
100+}
101+
68102 BOOL cmd_migemo_match(sObject* nextin, sObject* nextout, sRunInfo* runinfo)
69103 {
70104 BOOL quiet = sRunInfo_option(runinfo, "-quiet");
@@ -171,6 +205,7 @@ BOOL cmd_migemo_match(sObject* nextin, sObject* nextout, sRunInfo* runinfo)
171205 else {
172206 onig_free(reg);
173207 }
208+
174209 }
175210 }
176211
@@ -184,6 +219,7 @@ int dl_init()
184219 uobject_init(migemo_object);
185220 uobject_put(gRootObject, "migemo", migemo_object);
186221 uobject_put(migemo_object, "match", NFUN_NEW_GC(cmd_migemo_match, NULL, TRUE));
222+ uobject_put(migemo_object, "querry", NFUN_NEW_GC(cmd_migemo_querry, NULL, TRUE));
187223 gMigemoCache = HASH_NEW_MALLOC(100);
188224
189225 return 0;
--- a/src/ext/migemo.so.xyzsh
+++ b/src/ext/migemo.so.xyzsh
@@ -74,22 +74,36 @@ root::run(
7474 )
7575 ) else (
7676 print 0 | var -local ALL_ASCII_ONLY
77+ print 0 | var -local ALL_FILES
7778
78- if (inputing | =~ '.*\/[a-zA-Z]+$') (
79- | if(|=~ '.*\/[a-zA-Z]+[^a-zA-z/]+$') (
79+ if(inputing | =~ '^.*\/$') (
80+#print 0 | p > /dev/null
81+ inputing | var -local no_migemo_string
82+ print "" | var -local migemo_string
83+
84+ print 1 | var -local ALL_FILES
85+ ) elif (inputing | =~ '^.*\/[a-zA-Z]+$') (
86+#print a | p > /dev/null
87+ | if(|=~ '^.*\/[a-zA-Z]+[^a-zA-z/]+$') (
8088 (inputing; |print) | common_head | var -local same_head
8189
8290 same_head | var -local no_migemo_string
8391 inputing | sub -no-regex $same_head '' | var -local migemo_string
8492 ) else (
85- inputing | sub '(.*\/)[a-zA-Z]+$' '\1' | var -local no_migemo_string
86- inputing | sub '.*\/([a-zA-Z]+)$' '\1' | var -local migemo_string
93+ inputing | sub '^(.*\/)[a-zA-Z]+$' '\1' | var -local no_migemo_string
94+ inputing | sub '^.*\/([a-zA-Z]+)$' '\1' | var -local migemo_string
8795 )
88- ) elif (inputing | =~ '.*\/[^a-zA-Z]+[a-zA-Z]+$') (
89- inputing | sub '(.*\/[^a-zA-Z]+)[a-zA-Z]+$' '\1' | var -local no_migemo_string
90- inputing | sub '.*\/[^a-zA-Z]+([a-zA-Z]+)$' '\1' | var -local migemo_string
91- ) elif (inputing | =~ '[a-zA-Z]+$') (
92- | if(|=~ '[a-zA-Z]+[^a-zA-z/]+$') (
96+ ) elif (inputing | =~ '^.*\/[^a-zA-Z]+[a-zA-Z]+$') (
97+#print b | p > /dev/null
98+ inputing | sub '^(.*\/[^a-zA-Z]+)[a-zA-Z]+$' '\1' | var -local no_migemo_string
99+ inputing | sub '^.*\/[^a-zA-Z]+([a-zA-Z]+)$' '\1' | var -local migemo_string
100+ ) elif (inputing | =~ '^.*\/[^a-zA-Z]+$') (
101+#print b2 | p > /dev/null
102+ inputing | var -local no_migemo_string
103+ print "" | var -local migemo_string
104+ ) elif (inputing | =~ '^[a-zA-Z]+$') (
105+#print c | p > /dev/null
106+ | if(|=~ '^[a-zA-Z]+[^a-zA-z/]+$') (
93107 (inputing; |print) | common_head | var -local same_head
94108
95109 same_head | var -local no_migemo_string
@@ -98,21 +112,33 @@ root::run(
98112 print "" | var -local no_migemo_string
99113 inputing | var -local migemo_string
100114 )
101- ) elif (inputing | =~ '[^a-zA-Z]+[a-zA-Z]+$') (
102- inputing | sub '([^a-zA-Z]+)[a-zA-Z]+$' '\1' | var -local no_migemo_string
103- inputing | sub '[^a-zA-Z]+([a-zA-Z]+)$' '\1' | var -local migemo_string
115+ ) elif (inputing | =~ '^[^a-zA-Z]+[a-zA-Z]+$') (
116+#print d | p > /dev/null
117+ inputing | sub '(^[^a-zA-Z]+)[a-zA-Z]+$' '\1' | var -local no_migemo_string
118+ inputing | sub '^[^a-zA-Z]+([a-zA-Z]+)$' '\1' | var -local migemo_string
119+ ) elif (inputing | =~ '^[^a-zA-Z]+$') (
120+ inputing | var -local no_migemo_string
121+ print "" | var -local migemo_string
104122 ) else (
123+#print e | p > /dev/null
105124 print "" | var -local no_migemo_string
106125 print "" | var -local migemo_string
107126 )
108127
109- | if(| sub -no-regex $no_migemo_string '' | chomp | migemo::match $migemo_string | lines 0 | = 0\n) (
128+#| p > /dev/null
129+ if(ALL_FILES | = 1\n) (
110130 | print
131+ ) else (
132+ | if(| index $no_migemo_string | = 0\n) (
133+ | if(| sub -no-regex $no_migemo_string '' | chomp | migemo::match $migemo_string | lines 0 | = 0\n) (
134+ | print
135+ )
136+ )
111137 )
112138 )
113139 ) | (| common_head | var -local COMMON_HEAD; | length -line-num | var -local NUM)
114140
115- if(ALL_ASCII_ONLY | = 0\n && COMMON_HEAD | chomp | -n && COMMON_HEAD | length | -gt $(inputing | length)) (
141+ if(ALL_ASCII_ONLY | = 0\n && COMMON_HEAD | chomp | -n) ( # && COMMON_HEAD | length | -gt $(inputing | length)) (
116142 rl::delete_text $(editing_line | rindex $inputing) $(rl::point)
117143 if(NUM | chomp | -eq 1 && COMMON_HEAD| chomp | rows -1 | != /) (
118144 rl::insert_text $COMMON_HEAD" "