@@ -2020,7 +2020,9 @@ def uid_expunge(uid_set)
2020
2020
# ==== Argument translation
2021
2021
#
2022
2022
# [+return+ options]
2023
- # Must be an Array. Return option names are strings.
2023
+ # Must be an Array. Return option names may be either strings or symbols.
2024
+ # +Range+ elements which begin and end with negative integers are encoded
2025
+ # for use with +PARTIAL+--any other ranges are converted to SequenceSet.
2024
2026
# Unlike +criteria+, other return option arguments are not automatically
2025
2027
# converted to SequenceSet.
2026
2028
#
@@ -3294,10 +3296,28 @@ def search_args(keys, charset_arg = nil, return: nil, charset: nil)
3294
3296
end
3295
3297
3296
3298
def convert_return_opts ( unconverted )
3297
- Array . try_convert ( unconverted ) or
3299
+ return_opts = Array . try_convert ( unconverted ) or
3298
3300
raise TypeError , "expected return options to be Array, got %s" % [
3299
3301
unconverted . class
3300
3302
]
3303
+ return_opts . map { |opt |
3304
+ case opt
3305
+ when Symbol then opt . to_s
3306
+ when Range then partial_range_last_or_seqset ( opt )
3307
+ else opt
3308
+ end
3309
+ }
3310
+ end
3311
+
3312
+ def partial_range_last_or_seqset ( range )
3313
+ case [ range . begin , range . end ]
3314
+ in [ Integer => first , Integer => last ] if first . negative? && last . negative?
3315
+ # partial-range-last [RFC9394]
3316
+ first <= last or raise DataFormatError , "empty range: %p" % [ range ]
3317
+ "#{ first } :#{ last } "
3318
+ else
3319
+ SequenceSet [ range ]
3320
+ end
3301
3321
end
3302
3322
3303
3323
def search_internal ( cmd , ...)
0 commit comments