2263 |
|
|
2264 |
my $format="\"%s"; |
my $format="\"%s"; |
2265 |
my @ucfields = map { param2field ($_) } @fielddisplaylist; |
my @ucfields = map { param2field ($_) } @fielddisplaylist; |
2266 |
# XXX ??? !!! Might want to use a newline or a more complex separator |
|
2267 |
# instead of a | here. |
# We are using ASCII octal 037 (unit separator) to separate the |
2268 |
foreach (@ucfields) { |
# fields in the query output. Note that the format strings are |
2269 |
|
# interpolated (quoted with ""'s), so make sure to escape any $ or @ |
2270 |
|
# signs. |
2271 |
|
foreach (@ucfields) { |
2272 |
if (fieldinfo ($_, 'fieldtype') eq 'date') { |
if (fieldinfo ($_, 'fieldtype') eq 'date') { |
2273 |
$format .= '|%{%Y-%m-%d %H:%M:%S %Z}D'; |
$format .= "\037%{%Y-%m-%d %H:%M:%S %Z}D"; |
2274 |
} elsif (fieldinfo ($_, 'fieldtype') eq 'enum') { |
} elsif (fieldinfo ($_, 'fieldtype') eq 'enum') { |
2275 |
$format .= '|%d'; |
$format .= "\037%d"; |
2276 |
} else { |
} else { |
2277 |
$format .= '|%s'; |
$format .= "\037%s"; |
2278 |
} |
} |
2279 |
} |
} |
2280 |
|
|
2281 |
$format .= "\" ".${NUMBER_FIELD}." ".join (" ", @ucfields); |
$format .= "\" ".${NUMBER_FIELD}." ".join (" ", @ucfields); |
2430 |
# Sort @query_results according to the rules in by_field(). |
# Sort @query_results according to the rules in by_field(). |
2431 |
# Using the "map, sort" idiom allows us to perform the expensive |
# Using the "map, sort" idiom allows us to perform the expensive |
2432 |
# split() only once per item, as opposed to during every comparison. |
# split() only once per item, as opposed to during every comparison. |
2433 |
my(@presplit_prs) = map { [ (split /\|/) ] } @query_results; |
my(@presplit_prs) = map { [ (split /\037/) ] } @query_results; |
2434 |
my(@sorted_prs); |
my(@sorted_prs); |
2435 |
my $sortby_fieldtype = fieldinfo ($sortby, 'fieldtype') || ''; |
my $sortby_fieldtype = fieldinfo ($sortby, 'fieldtype') || ''; |
2436 |
if ($sortby_fieldtype eq 'enum' || $sortby_fieldtype eq 'integer' |
if ($sortby_fieldtype eq 'enum' || $sortby_fieldtype eq 'integer' |