@@ -1996,7 +1996,9 @@ def uid_expunge(uid_set)
1996
1996
# ==== Argument translation
1997
1997
#
1998
1998
# [+return+ options]
1999
- # Must be an Array. Return option names are strings.
1999
+ # Must be an Array. Return option names may be either strings or symbols.
2000
+ # +Range+ elements which begin and end with negative integers are encoded
2001
+ # for use with +PARTIAL+--any other ranges are converted to SequenceSet.
2000
2002
# Unlike +criteria+, other return option arguments are not automatically
2001
2003
# converted to SequenceSet.
2002
2004
#
@@ -3270,10 +3272,28 @@ def search_args(keys, charset_arg = nil, return: nil, charset: nil)
3270
3272
end
3271
3273
3272
3274
def convert_return_opts ( unconverted )
3273
- Array . try_convert ( unconverted ) or
3275
+ return_opts = Array . try_convert ( unconverted ) or
3274
3276
raise TypeError , "expected return options to be Array, got %s" % [
3275
3277
unconverted . class
3276
3278
]
3279
+ return_opts . map { |opt |
3280
+ case opt
3281
+ when Symbol then opt . to_s
3282
+ when Range then partial_range_last_or_seqset ( opt )
3283
+ else opt
3284
+ end
3285
+ }
3286
+ end
3287
+
3288
+ def partial_range_last_or_seqset ( range )
3289
+ case [ range . begin , range . end ]
3290
+ in [ Integer => first , Integer => last ] if first . negative? && last . negative?
3291
+ # partial-range-last [RFC9394]
3292
+ first <= last or raise DataFormatError , "empty range: %p" % [ range ]
3293
+ "#{ first } :#{ last } "
3294
+ else
3295
+ SequenceSet [ range ]
3296
+ end
3277
3297
end
3278
3298
3279
3299
def search_internal ( cmd , ...)
0 commit comments