Skip to content

Commit 4e052bc

Browse files
committed
CHANGE: when using block as a query field, get-words are required to get just the value
related to: Oldes/Rebol-issues#2607
1 parent cd8df5c commit 4e052bc

17 files changed

+82
-45
lines changed

src/core/c-frame.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,7 @@
11801180
*/ REBSER* Get_Object_Words(REBVAL *object)
11811181
/*
11821182
** Returns block of object's words converted to simple word (not set-word)
1183-
** Note: used in query/mode function to return default modes
1183+
** Note: used in query function to return default modes
11841184
**
11851185
***********************************************************************/
11861186
{

src/core/p-console.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,11 @@
217217
REBVAL *word = VAL_BLK_DATA(info);
218218
for (; NOT_END(word); word++) {
219219
if (ANY_WORD(word)) {
220-
if (IS_SET_WORD(word)) {
221-
// keep the set-word in result
220+
if (!IS_GET_WORD(word)) {
221+
// keep the word as a key (converted to the set-word) in the result
222222
val = Append_Value(values);
223223
*val = *word;
224+
VAL_TYPE(val) = REB_SET_WORD;
224225
VAL_SET_LINE(val);
225226
}
226227
val = Append_Value(values);

src/core/p-file.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -170,21 +170,22 @@
170170
Trap1(RE_INVALID_ARG, info);
171171
} else if (IS_BLOCK(info)) {
172172
// example:
173-
// query/mode file [type size] ;== [file 1234]
173+
// query file [:type :size] ;== [file 1234]
174174
// or:
175-
// query/mode file [type: size:] ;== [type: file size: 1234]
175+
// query file [type size] ;== [type: file size: 1234]
176176
// or combined:
177-
// query/mode file [type: size] ;== [type: file 1234]
177+
// query file [type: :size] ;== [type: file 1234]
178178
// When not supported word is used, if will throw an error
179179

180180
REBSER *values = Make_Block(2 * BLK_LEN(VAL_SERIES(info)));
181181
REBVAL *word = VAL_BLK_DATA(info);
182182
for (; NOT_END(word); word++) {
183183
if(ANY_WORD(word)) {
184-
if (IS_SET_WORD(word)) {
185-
// keep the set-word in result
184+
if (!IS_GET_WORD(word)) {
185+
// keep the word as a key (converted to the set-word) in the result
186186
val = Append_Value(values);
187187
*val = *word;
188+
VAL_TYPE(val) = REB_SET_WORD;
188189
VAL_SET_LINE(val);
189190
}
190191
val = Append_Value(values);

src/core/p-midi.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,11 @@
157157
REBVAL *word = VAL_BLK_DATA(field);
158158
for (; NOT_END(word); word++) {
159159
if (ANY_WORD(word)) {
160-
if (IS_SET_WORD(word)) {
161-
// keep the set-word in result
160+
if (!IS_GET_WORD(word)) {
161+
// keep the word as a key (converted to the set-word) in the result
162162
val = Append_Value(values);
163163
*val = *word;
164+
VAL_TYPE(val) = REB_SET_WORD;
164165
VAL_SET_LINE(val);
165166
}
166167
val = Append_Value(values);

src/core/p-net.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,22 @@ enum Transport_Types {
8282
}
8383
else if (IS_BLOCK(info)) {
8484
// example:
85-
// query/mode port [remote-ip remote-port] ;== [127.0.0.1 1234]
85+
// query port [:remote-ip :remote-port] ;== [127.0.0.1 1234]
8686
// or:
87-
// query/mode port [remote-ip: remote-port:] ;== [remote-ip: 127.0.0.1 remote-port: 1234]
87+
// query port [remote-ip remote-port] ;== [remote-ip: 127.0.0.1 remote-port: 1234]
8888
// or combined:
89-
// query/mode file [remote-ip: remote-port] ;== [remote-ip: 127.0.0.1 1234]
89+
// query file [remote-ip: :remote-port] ;== [remote-ip: 127.0.0.1 1234]
9090
// When not supported word is used, if will throw an error
9191

9292
REBSER *values = Make_Block(2 * BLK_LEN(VAL_SERIES(info)));
9393
REBVAL *word = VAL_BLK_DATA(info);
9494
for (; NOT_END(word); word++) {
9595
if (ANY_WORD(word)) {
96-
if (IS_SET_WORD(word)) {
97-
// keep the set-word in result
96+
if (!IS_GET_WORD(word)) {
97+
// keep the word as a key (converted to the set-word) in the result
9898
val = Append_Value(values);
9999
*val = *word;
100+
VAL_TYPE(val) = REB_SET_WORD;
100101
VAL_SET_LINE(val);
101102
}
102103
val = Append_Value(values);

src/core/t-date.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -1049,7 +1049,7 @@ static const REBI64 DAYS_OF_JAN_1ST_1970 = 719468; // number of days for 1st Jan
10491049
case A_QUERY:
10501050
spec = Get_System(SYS_STANDARD, STD_DATE_INFO);
10511051
if (!IS_OBJECT(spec)) Trap_Arg(spec);
1052-
REBVAL *field = D_ARG(3);
1052+
REBVAL *field = D_ARG(ARG_QUERY_FIELD);
10531053
if(IS_WORD(field)) {
10541054
switch(VAL_WORD_CANON(field)) {
10551055
case SYM_WORDS:
@@ -1067,10 +1067,11 @@ static const REBI64 DAYS_OF_JAN_1ST_1970 = 719468; // number of days for 1st Jan
10671067
REBVAL *word = VAL_BLK_DATA(field);
10681068
for (; NOT_END(word); word++) {
10691069
if (ANY_WORD(word)) {
1070-
if (IS_SET_WORD(word)) {
1071-
// keep the set-word in result
1070+
if (!IS_GET_WORD(word)) {
1071+
// keep the word as a key (converted to the set-word) in the result
10721072
out = Append_Value(values);
10731073
*out = *word;
1074+
VAL_TYPE(out) = REB_SET_WORD;
10741075
VAL_SET_LINE(out);
10751076
}
10761077
out = Append_Value(values);

src/core/t-handle.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ extern void RXI_To_Value(REBVAL *val, RXIARG arg, REBCNT type); // f-extension.c
180180
//TODO: this code could be made resusable with other types!
181181
spec = Get_System(SYS_STANDARD, STD_HANDLE_INFO);
182182
if (!IS_OBJECT(spec)) Trap_Arg(spec);
183-
REBVAL *field = D_ARG(3);
183+
REBVAL *field = D_ARG(ARG_QUERY_FIELD);
184184
if (IS_WORD(field)) {
185185
switch (VAL_WORD_CANON(field)) {
186186
case SYM_WORDS:
@@ -198,10 +198,11 @@ extern void RXI_To_Value(REBVAL *val, RXIARG arg, REBCNT type); // f-extension.c
198198
REBVAL *word = VAL_BLK_DATA(field);
199199
for (; NOT_END(word); word++) {
200200
if (ANY_WORD(word)) {
201-
if (IS_SET_WORD(word)) {
201+
if (!IS_GET_WORD(word)) {
202202
// keep the set-word in result
203203
out = Append_Value(values);
204204
*out = *word;
205+
VAL_TYPE(out) = REB_SET_WORD;
205206
VAL_SET_LINE(out);
206207
}
207208
out = Append_Value(values);

src/core/t-vector.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -842,10 +842,11 @@ static void reverse_vector(REBVAL *value, REBCNT len)
842842
REBVAL *word = VAL_BLK_DATA(field);
843843
for (; NOT_END(word); word++) {
844844
if (ANY_WORD(word)) {
845-
if (IS_SET_WORD(word)) {
846-
// keep the set-word in result
845+
if (!IS_GET_WORD(word)) {
846+
// keep the word as a key (converted to the set-word) in the result
847847
val = Append_Value(values);
848848
*val = *word;
849+
VAL_TYPE(val) = REB_SET_WORD;
849850
VAL_SET_LINE(val);
850851
}
851852
val = Append_Value(values);

src/mezz/mezz-files.reb

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ list-dir: closure/with [
274274
value depth
275275
/local info date time size
276276
][
277-
info: query value [name size date]
277+
info: query value [:name :size :date]
278278
unless info [
279279
return ajoin [
280280
"^[[1;35m *** Invalid symbolic link: ^[[0;35m"

src/mezz/prot-tls.reb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2035,7 +2035,7 @@ TLS-server-awake: func [event /local port info serv] [
20352035
accept [
20362036
serv: event/port
20372037
port: first serv
2038-
info: query port [remote-ip: remote-port:]
2038+
info: query port [remote-ip remote-port]
20392039
;? info
20402040
;? serv
20412041
port/extra: make TLS-context [

src/modules/httpd.reb

+3-3
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ sys/make-scheme [
263263
return Actor/On-List-Dir ctx target
264264
]
265265
]
266-
info: query path [modified: size:]
266+
info: query path [modified size]
267267
; prepare modified date of the target
268268
modified: info/modified
269269
modified/timezone: 0 ; converted to UTC
@@ -417,7 +417,7 @@ sys/make-scheme [
417417
append files dirs
418418

419419
foreach file files [
420-
set [size date] query/mode dir/:file [size date]
420+
set [size date] query dir/:file [:size :date]
421421
append out ajoin [
422422
{<a href="} file {">} file {</a> }
423423
pad copy "" 50 - length? file
@@ -846,7 +846,7 @@ sys/make-scheme [
846846

847847
New-Client: func[port [port!] /local client info err][
848848
client: first port
849-
info: query client [remote-ip: remote-port:]
849+
info: query client [remote-ip remote-port]
850850
unless Actor/On-Accept info [
851851
; connection not allowed
852852
log-more ["Client not accepted:^[[22m" info/remote-ip]

src/tests/test-midi.r3

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Rebol [
77
Needs: 3.11.0
88
]
99

10-
midi: query midi:// [devices-in: devices-out:]
10+
midi: query midi:// [devices-in devices-out]
1111
unless block? midi [ print as-purple "No MIDI available!" quit]
1212

1313
print [as-yellow "Input devices: " length? midi/devices-in]

src/tests/test-raw-tcp-read.r3

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ wp/awake: func [event /local port] [
2020
read [print ["^/read:" length? port/data] read port]
2121
wrote [read port]
2222
lookup [
23-
print query port [remote-ip: remote-port:]
23+
print query port [remote-ip remote-port]
2424
open port
2525
]
2626
connect [write port http-request]

src/tests/units/date-test.r3

+34-4
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,43 @@ Rebol [
358358
all-date-words: words-of system/standard/date-info
359359
--assert all-date-words = query date none
360360
--assert date/time = query date 'time
361-
--assert [2020 4] = query date [year month]
362-
--assert [month: 4 year: 2020] = query date [month: year:]
363-
--assert equal? query date all-date-words [2020 4 8 12:04:32 8-Apr-2020 2:00 12 4 32 3 99 2:00 8-Apr-2020/10:04:32 2458947.91981481]
361+
--assert [2020 4] = query date [:year :month]
362+
--assert [month: 4 year: 2020] = query date [month year]
363+
--assert equal? query date all-date-words [
364+
year: 2020
365+
month: 4
366+
day: 8
367+
time: 12:04:32
368+
date: 8-Apr-2020
369+
zone: 2:00
370+
hour: 12
371+
minute: 4
372+
second: 32
373+
weekday: 3
374+
yearday: 99
375+
timezone: 2:00
376+
utc: 8-Apr-2020/10:04:32
377+
julian: 2458947.91981481
378+
]
364379

365380
--test-- "query date"
366381
date: 8-Apr-2020 ; no time!
367-
--assert equal? query date all-date-words [2020 4 8 #(none) 2020-04-08 #(none) #(none) #(none) #(none) 3 99 #(none) 2020-04-08 2458948.0]
382+
--assert equal? query date all-date-words [
383+
year: 2020
384+
month: 4
385+
day: 8
386+
time: #(none)
387+
date: 8-Apr-2020
388+
zone: #(none)
389+
hour: #(none)
390+
minute: #(none)
391+
second: #(none)
392+
weekday: 3
393+
yearday: 99
394+
timezone: #(none)
395+
utc: 8-Apr-2020
396+
julian: 2458948.0
397+
]
368398

369399
===end-group===
370400

src/tests/units/file-test.r3

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ if find [Linux macOS] system/platform [
201201
===start-group=== "QUERY"
202202
--test-- "query dates"
203203
write %query-test "test"
204-
probe fields: [modified created accessed]
204+
fields: [:modified :created :accessed]
205205
--assert all [
206206
block? probe dates1: query %query-test fields
207207
date? dates1/1

src/tests/units/port-test.r3

+7-7
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ if system/platform = 'Windows [
235235
--assert 'file = query file 'type
236236
--assert date? query file 'modified
237237
--assert 51732 = query file 'size
238-
--assert [file 51732] = query file [type size]
239-
--assert [type: file size: 51732] = query file [type: size:]
238+
--assert [file 51732] = query file [:type :size]
239+
--assert [type: file size: 51732] = query file [type size]
240240

241241
--test-- "query file name"
242242
;@@ https://github.com/Oldes/Rebol-issues/issues/2442
@@ -250,8 +250,8 @@ if system/platform = 'Windows [
250250
--assert 'file = query file 'type
251251
--assert date? query file 'modified
252252
--assert 51732 = query file 'size
253-
--assert [file 51732] = query file [type size]
254-
--assert [type: file size: 51732] = query file [type: size:]
253+
--assert [file 51732] = query file [:type :size]
254+
--assert [type: file size: 51732] = query file [type size]
255255
close file
256256

257257
--test-- "write/lines"
@@ -695,7 +695,7 @@ if all [
695695
--assert (words-of system/standard/console-info)
696696
= m: query system/ports/input none
697697
--assert block? v: query system/ports/input m
698-
--assert 4 = length? v
698+
--assert 8 = length? v
699699
===end-group===
700700
]
701701

@@ -733,8 +733,8 @@ if all [
733733
--assert all [
734734
port? wait [port 1] ;= wait for lookup, so remote-ip is resolved
735735
8.8.8.8 = query port 'remote-ip
736-
[80 8.8.8.8] = query port [remote-port remote-ip]
737-
[local-ip: 0.0.0.0 local-port: 0] = query port [local-ip: local-port:]
736+
[80 8.8.8.8] = query port [:remote-port :remote-ip]
737+
[local-ip: 0.0.0.0 local-port: 0] = query port [local-ip local-port]
738738
]
739739
try [close port]
740740
===end-group===

src/tests/units/vector-test.r3

+4-4
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ Rebol [
158158
3 4
159159
]}
160160

161-
--test-- "QUERY on vector"
161+
--test-- "QUERY on vector as object"
162162
;@@ https://github.com/Oldes/Rebol-issues/issues/2352
163163
v: make vector! [unsigned integer! 16 2]
164164
o: query v object!
@@ -167,10 +167,10 @@ Rebol [
167167
--assert o/type = 'integer!
168168
--assert o/size = 16
169169
--assert o/length = 2
170-
--test-- "QUERY/MODE on vector"
170+
--test-- "QUERY on vector"
171171
--assert [signed type size length] = query v none
172-
--assert [16 integer!] = query v [size type]
173-
--assert block? b: query v [signed: length:]
172+
--assert [16 integer!] = query v [:size :type]
173+
--assert block? b: query v [signed length]
174174
--assert all [not b/signed b/length = 2]
175175
--assert 16 = query v 'size
176176
--assert 16 = size? v

0 commit comments

Comments
 (0)