Ruby GTK3移行後のメインリポジトリ
修訂 | e492695b5abb72679e6d58d99796a448bf1ad3b2 (tree) |
---|---|
時間 | 2015-07-12 13:11:11 |
作者 | Shyouzou Sugitani <shy@user...> |
Commiter | Shyouzou Sugitani |
assorted fixes(35)
@@ -43,12 +43,12 @@ module DLL | ||
43 | 43 | end |
44 | 44 | @dir = dir |
45 | 45 | result = 0 |
46 | - if check_import != 0 | |
46 | + if check_import == 0 | |
47 | 47 | #pass |
48 | 48 | elsif @loaded != 0 |
49 | 49 | result = 2 |
50 | 50 | else |
51 | - if setup() != 0 | |
51 | + if setup != 0 | |
52 | 52 | @loaded = 1 |
53 | 53 | result = 1 |
54 | 54 | end |
@@ -409,7 +409,7 @@ module Aya | ||
409 | 409 | elsif key == 'aitalkinterval' # Ver.3 |
410 | 410 | if not @global_namespace.exists('aitalkinterval') |
411 | 411 | begin |
412 | - value.to_i | |
412 | + Integer(value) | |
413 | 413 | rescue |
414 | 414 | Logging::Logging.debug( |
415 | 415 | 'Could not convert ' + value.to_s + ' to an integer') |
@@ -419,9 +419,9 @@ module Aya | ||
419 | 419 | end |
420 | 420 | elsif key != nil and not key.empty? |
421 | 421 | begin |
422 | - value = value.to_i | |
422 | + value = Integer(value) | |
423 | 423 | rescue |
424 | - value = value | |
424 | + value = value.to_s | |
425 | 425 | end |
426 | 426 | @global_namespace.put(key, value) |
427 | 427 | end |
@@ -485,9 +485,9 @@ module Aya | ||
485 | 485 | key, value = line.split(':', 2) |
486 | 486 | key.strip! |
487 | 487 | value.strip! |
488 | - if value =~ /[[:digit:]]/ | |
489 | - value = value.to_i | |
490 | - else | |
488 | + begin | |
489 | + value = Integer(value) | |
490 | + rescue | |
491 | 491 | value = value.to_s |
492 | 492 | end |
493 | 493 | @req_key << key |
@@ -1804,14 +1804,12 @@ module Aya | ||
1804 | 1804 | if var[0] == TYPE_ARRAY # _argv[n] only |
1805 | 1805 | index = evaluate_token(namespace, var[1][1]) |
1806 | 1806 | begin |
1807 | - index = index.to_i | |
1807 | + index = Integer(index) | |
1808 | 1808 | rescue |
1809 | 1809 | Logging::Logging.debug( |
1810 | 1810 | 'index of array has to be integer: ' \ |
1811 | 1811 | '' + var_name.to_s + '[' + var[1][1][0].to_s + ']') |
1812 | 1812 | return nil |
1813 | - else | |
1814 | - index = nil | |
1815 | 1813 | end |
1816 | 1814 | end |
1817 | 1815 | if value.is_a?(Fixnum) or value.is_a?(Float) |
@@ -1899,7 +1897,7 @@ module Aya | ||
1899 | 1897 | index = evaluate_token(namespace, line[1][0]) |
1900 | 1898 | inner_block = line[1][1] |
1901 | 1899 | begin |
1902 | - index = index.to_i | |
1900 | + index = Integer(index) | |
1903 | 1901 | rescue |
1904 | 1902 | index = 0 |
1905 | 1903 | end |
@@ -1984,7 +1982,7 @@ module Aya | ||
1984 | 1982 | @nonoverlap[0] = list_ |
1985 | 1983 | @nonoverlap[2] = [] |
1986 | 1984 | end |
1987 | - if not @nonoverlap[2] | |
1985 | + if @nonoverlap[2].empty? | |
1988 | 1986 | @nonoverlap[2] << ([0] * result.length) |
1989 | 1987 | while true |
1990 | 1988 | new = [] |
@@ -2040,7 +2038,7 @@ module Aya | ||
2040 | 2038 | else |
2041 | 2039 | index = evaluate_token(namespace, left[1][1]) |
2042 | 2040 | begin |
2043 | - index = index.to_i | |
2041 | + index = Integer(index) | |
2044 | 2042 | rescue |
2045 | 2043 | Logging::Logging.debug('Could not convert ' + index.to_s + ' to an integer') |
2046 | 2044 | else |
@@ -2136,7 +2134,7 @@ module Aya | ||
2136 | 2134 | end |
2137 | 2135 | index = evaluate_token(namespace, token[1][1]) |
2138 | 2136 | begin |
2139 | - index = index.to_i | |
2137 | + index = Integer(index) | |
2140 | 2138 | rescue |
2141 | 2139 | Logging::Logging.debug( |
2142 | 2140 | 'index of array has to be integer: ' + var_name.to_s + '[' + token[1][1].to_s + ']') |
@@ -2172,7 +2170,7 @@ module Aya | ||
2172 | 2170 | end |
2173 | 2171 | index = evaluate_token(namespace, token[1][1]) |
2174 | 2172 | begin |
2175 | - index = index.to_i | |
2173 | + index = Integer(index) | |
2176 | 2174 | rescue |
2177 | 2175 | Logging::Logging.debug( |
2178 | 2176 | 'index of array has to be integer: ' + var_name.to_s + '[' + token[1][1].to_s + ']') |
@@ -2444,7 +2442,7 @@ module Aya | ||
2444 | 2442 | index_token = parse_token(line[startpoint + 2..endpoint-1]) |
2445 | 2443 | index = evaluate_token(namespace, index_token) |
2446 | 2444 | begin |
2447 | - index = index.to_i | |
2445 | + index = Integer(index) | |
2448 | 2446 | rescue |
2449 | 2447 | Logging::Logging.debug( |
2450 | 2448 | 'illegal history index in the string(' + line + ')') |
@@ -2576,11 +2574,11 @@ module Aya | ||
2576 | 2574 | line[endpoint + 1..end_of_block-1]) |
2577 | 2575 | index = evaluate_token(namespace, index_token) |
2578 | 2576 | begin |
2579 | - index = index.to_i | |
2577 | + index = Integer(index) | |
2580 | 2578 | rescue |
2581 | 2579 | have_index = false |
2580 | + index = nil | |
2582 | 2581 | end |
2583 | - index = nil | |
2584 | 2582 | end |
2585 | 2583 | value = target_namespace.get(token, index) |
2586 | 2584 | if value != nil |
@@ -3362,13 +3360,13 @@ module Aya | ||
3362 | 3360 | def REQUESTLIB(namespace, argv) |
3363 | 3361 | response = @aya.saori_library.request( |
3364 | 3362 | argv[0].to_s, |
3365 | - argv[1].to_s.encode('Shift_JIS', 'ignore')) ## FIXME | |
3366 | - header = response.encode("UTF-8", :invalid => :replace, :undef => :replace).splitlines() | |
3363 | + argv[1].to_s.encode('Shift_JIS', :invalid => :replace, :undef => :replace)) ## FIXME | |
3364 | + header = response.encode("UTF-8", :invalid => :replace, :undef => :replace).split(/\r?\n/) | |
3367 | 3365 | @saori_statuscode = '' |
3368 | 3366 | @saori_header = [] |
3369 | 3367 | @saori_value = {} |
3370 | 3368 | @saori_protocol = '' |
3371 | - if header | |
3369 | + if header and not header.empty? | |
3372 | 3370 | line = header.shift |
3373 | 3371 | line = line.strip() |
3374 | 3372 | if line.include?(' ') |
@@ -126,7 +126,7 @@ module Bln | ||
126 | 126 | end |
127 | 127 | |
128 | 128 | def execute(argument) |
129 | - if not argument | |
129 | + if not argument or argument.empty? | |
130 | 130 | return RESPONSE[400] |
131 | 131 | end |
132 | 132 | name = argument[0] |
@@ -169,7 +169,7 @@ module Bln | ||
169 | 169 | bln[bln_id].destroy() |
170 | 170 | bln.delete(bln_id) |
171 | 171 | end |
172 | - if text | |
172 | + if not text.empty? | |
173 | 173 | if update == 0 or not bln.include?(bln_id) |
174 | 174 | bln[bln_id] = Balloon.new(@__sakura, @dir, |
175 | 175 | data, text, |
@@ -810,7 +810,7 @@ module Bln | ||
810 | 810 | @text = [@text, @processed_text[0]].join("") |
811 | 811 | draw_text(@text) |
812 | 812 | @processed_text = @processed_text[1..-1] |
813 | - @script_wait = time.time() + 0.014 | |
813 | + @script_wait = Time.now + 0.014 | |
814 | 814 | end |
815 | 815 | return |
816 | 816 | end |
@@ -36,7 +36,7 @@ module Makoto | ||
36 | 36 | if i + 1 < j and '(|)'.include?(s[i + 1]) |
37 | 37 | buf << s[i + 1] |
38 | 38 | else |
39 | - buf << s[i, i + 2] | |
39 | + buf << s[i..i + 1] | |
40 | 40 | end |
41 | 41 | i += 2 |
42 | 42 | elsif s[i] == '(' |
@@ -317,15 +317,15 @@ module Sakura | ||
317 | 317 | key, value = line.split(',', 2) |
318 | 318 | key = key.strip() |
319 | 319 | if key == 'time' |
320 | - if value.strip() =~ /[[:digit:]]/ | |
321 | - ghost_time = value.strip().to_i | |
322 | - else | |
320 | + begin | |
321 | + ghost_time = Integer(value.strip()) | |
322 | + rescue | |
323 | 323 | #pass |
324 | 324 | end |
325 | 325 | elsif key == 'vanished_count' |
326 | - if value.strip() =~ /[[:digit:]]/ | |
327 | - ghost_vanished_count = value.strip().to_i | |
328 | - else | |
326 | + begin | |
327 | + ghost_vanished_count = Integer(value.strip()) | |
328 | + rescue | |
329 | 329 | #pass |
330 | 330 | end |
331 | 331 | end |
@@ -2343,14 +2343,11 @@ module Sakura | ||
2343 | 2343 | end |
2344 | 2344 | |
2345 | 2345 | def __yen_exclamation(args) ## FIXME |
2346 | - if not args.empty? | |
2346 | + if args.empty? | |
2347 | 2347 | return |
2348 | 2348 | end |
2349 | 2349 | argc = args.length |
2350 | - args = [] | |
2351 | - for s in args | |
2352 | - args << expand_meta(s) | |
2353 | - end | |
2350 | + args = args.map {|s| expand_meta(s)} | |
2354 | 2351 | if args[0] == 'raise' and argc >= 2 |
2355 | 2352 | notify_event(*args[1, 9]) |
2356 | 2353 | elsif args[0, 2] == ['open', 'readme'] |