excel_to_code 0.3.18.beta.2 → 0.3.18
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a3957e729191cbc51037a420413ad74da28146727732dad6b681d82dc3dc186
|
4
|
+
data.tar.gz: 8dc0f9e740b1826f953fc58da6a6a533f45019a1e64a6d69a2c9435a084ff570
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a7fcd36058406db53cca24714416d25f6ee2f1f20ba4d97d57632a1d6cd42992243add6f66c835d0264db6a3d9d4f658e063a8c374e36a0445aaea9016e273e
|
7
|
+
data.tar.gz: 623215bcb5cf2b1b20708c86e75976db740ebcc180ad8d93f9587e98ae17e0c3f886c3504fe4051e96050c101560065986db4c2a31953f502b81839ff5a7adb0
|
data/src/compile/c/a.out
CHANGED
Binary file
|
@@ -2215,18 +2215,30 @@ static ExcelValue filter_range(ExcelValue original_range_v, int number_of_argume
|
|
2215
2215
|
|
2216
2216
|
if(current_value.type == ExcelString) {
|
2217
2217
|
s = current_value.string;
|
2218
|
+
while(s[0] == ' ') {
|
2219
|
+
s = s + 1;
|
2220
|
+
}
|
2218
2221
|
if(s[0] == '<') {
|
2219
2222
|
if( s[1] == '>') {
|
2223
|
+
while(s[2] == ' ') {
|
2224
|
+
s = s + 1;
|
2225
|
+
}
|
2220
2226
|
new_comparator = strndup(s+2,strlen(s)-2);
|
2221
2227
|
free_later(new_comparator);
|
2222
2228
|
criteria[i].type = NotEqual;
|
2223
2229
|
criteria[i].comparator = EXCEL_STRING(new_comparator);
|
2224
2230
|
} else if(s[1] == '=') {
|
2231
|
+
while(s[2] == ' ') {
|
2232
|
+
s = s + 1;
|
2233
|
+
}
|
2225
2234
|
new_comparator = strndup(s+2,strlen(s)-2);
|
2226
2235
|
free_later(new_comparator);
|
2227
2236
|
criteria[i].type = LessThanOrEqual;
|
2228
2237
|
criteria[i].comparator = EXCEL_STRING(new_comparator);
|
2229
2238
|
} else {
|
2239
|
+
while(s[1] == ' ') {
|
2240
|
+
s = s + 1;
|
2241
|
+
}
|
2230
2242
|
new_comparator = strndup(s+1,strlen(s)-1);
|
2231
2243
|
free_later(new_comparator);
|
2232
2244
|
criteria[i].type = LessThan;
|
@@ -2234,17 +2246,26 @@ static ExcelValue filter_range(ExcelValue original_range_v, int number_of_argume
|
|
2234
2246
|
}
|
2235
2247
|
} else if(s[0] == '>') {
|
2236
2248
|
if(s[1] == '=') {
|
2249
|
+
while(s[2] == ' ') {
|
2250
|
+
s = s + 1;
|
2251
|
+
}
|
2237
2252
|
new_comparator = strndup(s+2,strlen(s)-2);
|
2238
2253
|
free_later(new_comparator);
|
2239
2254
|
criteria[i].type = MoreThanOrEqual;
|
2240
2255
|
criteria[i].comparator = EXCEL_STRING(new_comparator);
|
2241
2256
|
} else {
|
2257
|
+
while(s[1] == ' ') {
|
2258
|
+
s = s + 1;
|
2259
|
+
}
|
2242
2260
|
new_comparator = strndup(s+1,strlen(s)-1);
|
2243
2261
|
free_later(new_comparator);
|
2244
2262
|
criteria[i].type = MoreThan;
|
2245
2263
|
criteria[i].comparator = EXCEL_STRING(new_comparator);
|
2246
2264
|
}
|
2247
2265
|
} else if(s[0] == '=') {
|
2266
|
+
while(s[1] == ' ') {
|
2267
|
+
s = s + 1;
|
2268
|
+
}
|
2248
2269
|
new_comparator = strndup(s+1,strlen(s)-1);
|
2249
2270
|
free_later(new_comparator);
|
2250
2271
|
criteria[i].type = Equal;
|
@@ -2466,18 +2487,30 @@ static ExcelValue countifs(int number_of_arguments, ExcelValue *arguments) {
|
|
2466
2487
|
|
2467
2488
|
if(current_value.type == ExcelString) {
|
2468
2489
|
s = current_value.string;
|
2490
|
+
while(s[0] == ' ') {
|
2491
|
+
s = s + 1;
|
2492
|
+
}
|
2469
2493
|
if(s[0] == '<') {
|
2470
2494
|
if( s[1] == '>') {
|
2495
|
+
while(s[2] == ' ') {
|
2496
|
+
s = s + 1;
|
2497
|
+
}
|
2471
2498
|
new_comparator = strndup(s+2,strlen(s)-2);
|
2472
2499
|
free_later(new_comparator);
|
2473
2500
|
criteria[i].type = NotEqual;
|
2474
2501
|
criteria[i].comparator = EXCEL_STRING(new_comparator);
|
2475
2502
|
} else if(s[1] == '=') {
|
2503
|
+
while(s[2] == ' ') {
|
2504
|
+
s = s + 1;
|
2505
|
+
}
|
2476
2506
|
new_comparator = strndup(s+2,strlen(s)-2);
|
2477
2507
|
free_later(new_comparator);
|
2478
2508
|
criteria[i].type = LessThanOrEqual;
|
2479
2509
|
criteria[i].comparator = EXCEL_STRING(new_comparator);
|
2480
2510
|
} else {
|
2511
|
+
while(s[1] == ' ') {
|
2512
|
+
s = s + 1;
|
2513
|
+
}
|
2481
2514
|
new_comparator = strndup(s+1,strlen(s)-1);
|
2482
2515
|
free_later(new_comparator);
|
2483
2516
|
criteria[i].type = LessThan;
|
@@ -2485,17 +2518,26 @@ static ExcelValue countifs(int number_of_arguments, ExcelValue *arguments) {
|
|
2485
2518
|
}
|
2486
2519
|
} else if(s[0] == '>') {
|
2487
2520
|
if(s[1] == '=') {
|
2521
|
+
while(s[2] == ' ') {
|
2522
|
+
s = s + 1;
|
2523
|
+
}
|
2488
2524
|
new_comparator = strndup(s+2,strlen(s)-2);
|
2489
2525
|
free_later(new_comparator);
|
2490
2526
|
criteria[i].type = MoreThanOrEqual;
|
2491
2527
|
criteria[i].comparator = EXCEL_STRING(new_comparator);
|
2492
2528
|
} else {
|
2529
|
+
while(s[1] == ' ') {
|
2530
|
+
s = s + 1;
|
2531
|
+
}
|
2493
2532
|
new_comparator = strndup(s+1,strlen(s)-1);
|
2494
2533
|
free_later(new_comparator);
|
2495
2534
|
criteria[i].type = MoreThan;
|
2496
2535
|
criteria[i].comparator = EXCEL_STRING(new_comparator);
|
2497
2536
|
}
|
2498
2537
|
} else if(s[0] == '=') {
|
2538
|
+
while(s[1] == ' ') {
|
2539
|
+
s = s + 1;
|
2540
|
+
}
|
2499
2541
|
new_comparator = strndup(s+1,strlen(s)-1);
|
2500
2542
|
free_later(new_comparator);
|
2501
2543
|
criteria[i].type = Equal;
|
@@ -2871,6 +2913,8 @@ static ExcelValue text(ExcelValue number_v, ExcelValue format_v) {
|
|
2871
2913
|
snprintf(s, 99, "%'0.3f",number_v.number);
|
2872
2914
|
} else if(strcmp(format_v.string,"0000") == 0) {
|
2873
2915
|
snprintf(s, 99, "%04.0f",number_v.number);
|
2916
|
+
} else if(strcmp(format_v.string,"#,000") == 0) {
|
2917
|
+
snprintf(s, 99, "%'03.0f",number_v.number);
|
2874
2918
|
} else {
|
2875
2919
|
snprintf(s, 99, "Text format not recognised");
|
2876
2920
|
}
|
@@ -585,6 +585,8 @@ int test_functions() {
|
|
585
585
|
|
586
586
|
ExcelValue sumifs_array_10f[] = { sumifs_array_3_v, EXCEL_STRING(">=3")};
|
587
587
|
assert(sumifs(sumifs_array_3_v,2, sumifs_array_10f).number == 17);
|
588
|
+
ExcelValue sumifs_array_10g[] = { sumifs_array_3_v, EXCEL_STRING(" >= 3")};
|
589
|
+
assert(sumifs(sumifs_array_3_v,2, sumifs_array_10g).number == 17);
|
588
590
|
|
589
591
|
// ... BLANK in check range should match empty strings, BLANK in criteria should match zero
|
590
592
|
ExcelValue sumifs_array_11[] = { BLANK, EXCEL_NUMBER(0)};
|
@@ -658,6 +660,9 @@ int test_functions() {
|
|
658
660
|
ExcelValue countifs_array_10e[] = { countifs_array_3_v, EXCEL_STRING(">3")};
|
659
661
|
assert(countifs(2, countifs_array_10e).number == 3.0);
|
660
662
|
|
663
|
+
ExcelValue countifs_array_10e2[] = { countifs_array_3_v, EXCEL_STRING("> 3")};
|
664
|
+
assert(countifs(2, countifs_array_10e2).number == 3.0);
|
665
|
+
|
661
666
|
ExcelValue countifs_array_10f[] = { countifs_array_3_v, EXCEL_STRING(">=3")};
|
662
667
|
assert(countifs(2, countifs_array_10f).number == 4.0);
|
663
668
|
|
@@ -890,6 +895,8 @@ int test_functions() {
|
|
890
895
|
assert(strcmp(text(EXCEL_NUMBER(123456789.123456), EXCEL_STRING("#,##")).string, "123,456,789") == 0);
|
891
896
|
assert(strcmp(text(EXCEL_NUMBER(123456789.123456), EXCEL_STRING("#,##0")).string, "123,456,789") == 0);
|
892
897
|
assert(strcmp(text(EXCEL_NUMBER(123456789.123456), EXCEL_STRING("#,##0.0")).string, "123,456,789.1") == 0);
|
898
|
+
assert(strcmp(text(EXCEL_NUMBER(3.1), EXCEL_STRING("#,000")).string, "003") == 0);
|
899
|
+
assert(strcmp(text(EXCEL_NUMBER(1000.3), EXCEL_STRING("#,000")).string, "1,000") == 0);
|
893
900
|
assert(strcmp(text(EXCEL_NUMBER(123456789.123456), EXCEL_STRING("!#,##0.0")).string, "Text format not recognised") == 0);
|
894
901
|
|
895
902
|
// Test LOG
|
@@ -69,7 +69,7 @@ module ExcelFunctions
|
|
69
69
|
when Numeric
|
70
70
|
check_value == required_value
|
71
71
|
when String
|
72
|
-
required_value =~
|
72
|
+
required_value =~ /^\s*(<=|>=|<|>)?\s*([-+]?[0-9]+\.?[0-9]*([eE][-+]?[0-9]+)?)\s*$/
|
73
73
|
if $1 && $2
|
74
74
|
check_value.send($1,$2.to_f)
|
75
75
|
elsif $2
|
@@ -20,9 +20,12 @@ module ExcelFunctions
|
|
20
20
|
text(number*100, $1)+"%"
|
21
21
|
when /^(0+)$/
|
22
22
|
sprintf("%0#{$1.length}.0f", number)
|
23
|
-
when
|
23
|
+
when /^#[,.]#*(0[.,]0+)?(0*)$/
|
24
24
|
formated_with_decimals = text(number, $1 || "0")
|
25
25
|
parts = formated_with_decimals.split('.')
|
26
|
+
if $2 && parts[0].length < $2.length
|
27
|
+
parts[0] = ("0"*($2.length - parts[0].length))+parts[0]
|
28
|
+
end
|
26
29
|
parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1,")
|
27
30
|
parts.join('.')
|
28
31
|
when /0[.,](0+)/
|
data/src/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excel_to_code
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.18
|
4
|
+
version: 0.3.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Counsell, Green on Black Ltd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubypeg
|
@@ -365,9 +365,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
365
365
|
version: 2.3.0
|
366
366
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
367
367
|
requirements:
|
368
|
-
- - "
|
368
|
+
- - ">="
|
369
369
|
- !ruby/object:Gem::Version
|
370
|
-
version:
|
370
|
+
version: '0'
|
371
371
|
requirements: []
|
372
372
|
rubyforge_project:
|
373
373
|
rubygems_version: 2.7.7
|