Re: Proposed fix for #687899 Input tray not retained |
Raph Levien <[email protected]> Thu, 31 Mar 2005 12:39:38 -0800
| Newsgroups | gmane.comp.printing.ghostscript.patches |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Mar 31, 2005 at 10:51:44AM -0800, Ray Johnston wrote:
> Raph,
>
> You forgot to include the modified zmedia2.c that has the change
> to support:
Oops, sorry. The full patch is attached.
> Also can you include the modifications that the customer will need to
> replace the InputAttributes dictionary and the sample you used for
> testing?
Here's the test snippet I used:
<<
/InputAttributes <<
0 << /PageSize [ 612 792 ] >>
1 << /PageSize [ 612 792 ] >>
2 << /PageSize [ 612 792 ] >>
5 << /PageSize [ 612 792 ] >>
>>
>> setpagedevice
<<
/ManualFeed false /MediaPosition 1
>> setpagedevice
> If you want someone else to test, you should ask specifically. I'm off
> the hook since I don't have a PCL capable printer.
I don't feel a strong need to test further on actual printers before
committing. I'm most concerned actually with overly aggressive PPD's
in Linux printing systems that set ManualFeed and MediaPosition even
when there is no real reason to - these may insert spurious media
selection commands into the resulting PCL. The only real way to shake
out those kinds of problems is to release.
> Once you send the other info, I'll be glad to do some testing of the
> selection logic (I'll just check for the string in the output, but I
> can't tell if it actually works to a printer).
Thanks!
Raph
_______________________________________________
gs-code-review mailing list
[email protected]
http://www.ghostscript.com/mailman/listinfo/gs-code-review
mediapos_patch
(text/plain, 19.3 KB)
Index: lib/gs_setpd.ps
===================================================================
RCS file: /cvs/ghostscript/gs/lib/gs_setpd.ps,v
retrieving revision 1.25
diff -C2 -r1.25 gs_setpd.ps
*** lib/gs_setpd.ps 13 Sep 2004 22:33:15 -0000 1.25
--- lib/gs_setpd.ps 31 Mar 2005 20:34:10 -0000
***************
*** 374,379 ****
ifelse copy readonly
} bind
- % Ignore MediaPostition when merging (Adobe CPSI does).
- /MediaPosition { dup //null ne { pop //null } if } bind
.dicttomark readonly def
--- 374,377 ----
Index: src/gdevdjet.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevdjet.c,v
retrieving revision 1.11
diff -C2 -r1.11 gdevdjet.c
*** src/gdevdjet.c 29 Jan 2004 18:19:41 -0000 1.11
--- src/gdevdjet.c 31 Mar 2005 20:34:10 -0000
***************
*** 112,203 ****
private dev_proc_print_page_copies(lp2563_print_page_copies);
private dev_proc_print_page_copies(oce9050_print_page_copies);
private const gx_device_procs prn_hp_procs =
prn_params_procs(hpjet_open, gdev_prn_output_page, hpjet_close,
! gdev_prn_get_params, gdev_prn_put_params);
! const gx_device_printer gs_deskjet_device =
! prn_device_copies(prn_hp_procs, "deskjet",
! DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
! X_DPI, Y_DPI,
! 0, 0, 0, 0, /* margins filled in by hpjet_open */
! 1, djet_print_page_copies);
!
! const gx_device_printer gs_djet500_device =
! prn_device_copies(prn_hp_procs, "djet500",
! DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
! X_DPI, Y_DPI,
! 0, 0, 0, 0, /* margins filled in by hpjet_open */
! 1, djet500_print_page_copies);
!
! const gx_device_printer gs_fs600_device =
! prn_device_copies(prn_hp_procs, "fs600",
! DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
! X_DPI2, Y_DPI2,
! 0.23, 0.0, 0.23, 0.04, /* margins */
! 1, fs600_print_page_copies);
!
! const gx_device_printer gs_laserjet_device =
! prn_device_copies(prn_hp_procs, "laserjet",
! DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
! X_DPI, Y_DPI,
! 0.05, 0.25, 0.55, 0.25, /* margins */
! 1, ljet_print_page_copies);
!
! const gx_device_printer gs_ljetplus_device =
! prn_device_copies(prn_hp_procs, "ljetplus",
! DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
! X_DPI, Y_DPI,
! 0.05, 0.25, 0.55, 0.25, /* margins */
! 1, ljetplus_print_page_copies);
!
! const gx_device_printer gs_ljet2p_device =
! prn_device_copies(prn_hp_procs, "ljet2p",
! DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
! X_DPI, Y_DPI,
! 0.20, 0.25, 0.25, 0.25, /* margins */
! 1, ljet2p_print_page_copies);
!
! const gx_device_printer gs_ljet3_device =
! prn_device_copies(prn_hp_procs, "ljet3",
! DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
! X_DPI, Y_DPI,
! 0.20, 0.25, 0.25, 0.25, /* margins */
! 1, ljet3_print_page_copies);
!
! const gx_device_printer gs_ljet3d_device =
! prn_device_copies(prn_hp_procs, "ljet3d",
! DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
! X_DPI, Y_DPI,
! 0.20, 0.25, 0.25, 0.25, /* margins */
! 1, ljet3d_print_page_copies);
!
! const gx_device_printer gs_ljet4_device =
! prn_device_copies(prn_hp_procs, "ljet4",
! DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
! X_DPI2, Y_DPI2,
! 0, 0, 0, 0, /* margins */
! 1, ljet4_print_page_copies);
!
! const gx_device_printer gs_ljet4d_device =
! prn_device_copies(prn_hp_procs, "ljet4d",
! DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
! X_DPI2, Y_DPI2,
! 0, 0, 0, 0, /* margins */
! 1, ljet4d_print_page_copies);
!
! const gx_device_printer gs_lp2563_device =
! prn_device_copies(prn_hp_procs, "lp2563",
! DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
! X_DPI, Y_DPI,
! 0, 0, 0, 0, /* margins */
! 1, lp2563_print_page_copies);
!
! const gx_device_printer gs_oce9050_device =
! prn_device_copies(prn_hp_procs, "oce9050",
! 24 * 10, 24 * 10, /* 24 inch roll (can print 32" also) */
! 400, 400, /* 400 dpi */
! 0, 0, 0, 0, /* margins */
! 1, oce9050_print_page_copies);
/* Open the printer, adjusting the margins if necessary. */
--- 112,222 ----
private dev_proc_print_page_copies(lp2563_print_page_copies);
private dev_proc_print_page_copies(oce9050_print_page_copies);
+ private dev_proc_get_params(hpjet_get_params);
+ private dev_proc_put_params(hpjet_put_params);
private const gx_device_procs prn_hp_procs =
prn_params_procs(hpjet_open, gdev_prn_output_page, hpjet_close,
! hpjet_get_params, hpjet_put_params);
! typedef struct gx_device_hpjet_s gx_device_hpjet;
!
! struct gx_device_hpjet_s {
! gx_device_common;
! gx_prn_device_common;
! int MediaPosition;
! bool MediaPosition_set;
! bool ManualFeed;
! bool ManualFeed_set;
! };
!
! #define HPJET_DEVICE(procs, dname, w10, h10, xdpi, ydpi, lm, bm, rm, tm, color_bits, print_page_copies)\
! { prn_device_std_margins_body_copies(gx_device_hpjet, procs, dname, \
! w10, h10, xdpi, ydpi, lm, tm, lm, bm, rm, tm, color_bits, \
! print_page_copies), \
! 0, false, false, false }
!
! const gx_device_hpjet gs_deskjet_device =
! HPJET_DEVICE(prn_hp_procs, "deskjet",
! DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
! X_DPI, Y_DPI,
! 0, 0, 0, 0, /* margins filled in by hpjet_open */
! 1, djet_print_page_copies);
!
! const gx_device_hpjet gs_djet500_device =
! HPJET_DEVICE(prn_hp_procs, "djet500",
! DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
! X_DPI, Y_DPI,
! 0, 0, 0, 0, /* margins filled in by hpjet_open */
! 1, djet500_print_page_copies);
!
! const gx_device_hpjet gs_fs600_device =
! HPJET_DEVICE(prn_hp_procs, "fs600",
! DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
! X_DPI2, Y_DPI2,
! 0.23, 0.0, 0.23, 0.04, /* margins */
! 1, fs600_print_page_copies);
!
! const gx_device_hpjet gs_laserjet_device =
! HPJET_DEVICE(prn_hp_procs, "laserjet",
! DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
! X_DPI, Y_DPI,
! 0.05, 0.25, 0.55, 0.25, /* margins */
! 1, ljet_print_page_copies);
!
! const gx_device_hpjet gs_ljetplus_device =
! HPJET_DEVICE(prn_hp_procs, "ljetplus",
! DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
! X_DPI, Y_DPI,
! 0.05, 0.25, 0.55, 0.25, /* margins */
! 1, ljetplus_print_page_copies);
!
! const gx_device_hpjet gs_ljet2p_device =
! HPJET_DEVICE(prn_hp_procs, "ljet2p",
! DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
! X_DPI, Y_DPI,
! 0.20, 0.25, 0.25, 0.25, /* margins */
! 1, ljet2p_print_page_copies);
!
! const gx_device_hpjet gs_ljet3_device =
! HPJET_DEVICE(prn_hp_procs, "ljet3",
! DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
! X_DPI, Y_DPI,
! 0.20, 0.25, 0.25, 0.25, /* margins */
! 1, ljet3_print_page_copies);
!
! const gx_device_hpjet gs_ljet3d_device =
! HPJET_DEVICE(prn_hp_procs, "ljet3d",
! DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
! X_DPI, Y_DPI,
! 0.20, 0.25, 0.25, 0.25, /* margins */
! 1, ljet3d_print_page_copies);
!
! const gx_device_hpjet gs_ljet4_device =
! HPJET_DEVICE(prn_hp_procs, "ljet4",
! DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
! X_DPI2, Y_DPI2,
! 0, 0, 0, 0, /* margins */
! 1, ljet4_print_page_copies);
!
! const gx_device_hpjet gs_ljet4d_device =
! HPJET_DEVICE(prn_hp_procs, "ljet4d",
! DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
! X_DPI2, Y_DPI2,
! 0, 0, 0, 0, /* margins */
! 1, ljet4d_print_page_copies);
!
! const gx_device_hpjet gs_lp2563_device =
! HPJET_DEVICE(prn_hp_procs, "lp2563",
! DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
! X_DPI, Y_DPI,
! 0, 0, 0, 0, /* margins */
! 1, lp2563_print_page_copies);
!
! const gx_device_hpjet gs_oce9050_device =
! HPJET_DEVICE(prn_hp_procs, "oce9050",
! 24 * 10, 24 * 10, /* 24 inch roll (can print 32" also) */
! 400, 400, /* 400 dpi */
! 0, 0, 0, 0, /* margins */
! 1, oce9050_print_page_copies);
/* Open the printer, adjusting the margins if necessary. */
***************
*** 264,267 ****
--- 283,306 ----
/* ------ Internal routines ------ */
+ /* Make an init string that contains paper tray selection. The resulting
+ init string is stored in buf, so make sure that buf is at least 5
+ bytes larger than str. */
+ private void
+ hpjet_make_init(gx_device_printer *pdev, char *buf, const char *str)
+ {
+ gx_device_hpjet *dev = (gx_device_hpjet *)pdev;
+ int paper_source = -1;
+ int paper_source_tab[] = { 5, 1 };
+
+ if (dev->ManualFeed_set && dev->ManualFeed) paper_source = 2;
+ else if (dev->MediaPosition_set && dev->MediaPosition >= 0 &&
+ dev->MediaPosition < countof(paper_source_tab))
+ paper_source = paper_source_tab[dev->MediaPosition];
+ if (paper_source >= 0)
+ sprintf(buf, "%s\033&l%dH", str, paper_source);
+ else
+ sprintf(buf, "%s", str);
+ }
+
/* The DeskJet can compress (mode 2) */
private int
***************
*** 269,275 ****
int num_copies)
{
return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
! 300, PCL_DJ_FEATURES,
! "\033&k1W\033*b2M");
}
/* The DeskJet500 can compress (modes 2&3) */
--- 308,316 ----
int num_copies)
{
+ char init[80];
+
+ hpjet_make_init(pdev, init, "\033&k1W\033*b2M");
return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
! 300, PCL_DJ_FEATURES, init);
}
/* The DeskJet500 can compress (modes 2&3) */
***************
*** 278,284 ****
int num_copies)
{
return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
! 300, PCL_DJ500_FEATURES,
! "\033&k1W");
}
/* The Kyocera FS-600 laser printer (and perhaps other printers */
--- 319,327 ----
int num_copies)
{
+ char init[80];
+
+ hpjet_make_init(pdev, init, "\033&k1W");
return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
! 300, PCL_DJ500_FEATURES, init);
}
/* The Kyocera FS-600 laser printer (and perhaps other printers */
***************
*** 290,299 ****
{
int dots_per_inch = (int)pdev->y_pixels_per_inch;
! char real_init[60];
! sprintf(real_init, "\033*r0F\033&u%dD", dots_per_inch);
return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
dots_per_inch, PCL_FS600_FEATURES,
! real_init);
}
/* The LaserJet series II can't compress */
--- 333,344 ----
{
int dots_per_inch = (int)pdev->y_pixels_per_inch;
! char base_init[60];
! char init[80];
! sprintf(base_init, "\033*r0F\033&u%dD", dots_per_inch);
! hpjet_make_init(pdev, init, base_init);
return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
dots_per_inch, PCL_FS600_FEATURES,
! init);
}
/* The LaserJet series II can't compress */
***************
*** 302,308 ****
int num_copies)
{
return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
! 300, PCL_LJ_FEATURES,
! "\033*b0M");
}
/* The LaserJet Plus can't compress */
--- 347,355 ----
int num_copies)
{
+ char init[80];
+
+ hpjet_make_init(pdev, init, "\033*b0M");
return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
! 300, PCL_LJ_FEATURES, init);
}
/* The LaserJet Plus can't compress */
***************
*** 311,317 ****
int num_copies)
{
return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
! 300, PCL_LJplus_FEATURES,
! "\033*b0M");
}
/* LaserJet series IIp & IId compress (mode 2) */
--- 358,366 ----
int num_copies)
{
+ char init[80];
+
+ hpjet_make_init(pdev, init, "\033*b0M");
return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
! 300, PCL_LJplus_FEATURES, init);
}
/* LaserJet series IIp & IId compress (mode 2) */
***************
*** 321,327 ****
int num_copies)
{
return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
! 300, PCL_LJ2p_FEATURES,
! "\033*r0F\033*b2M");
}
/* All LaserJet series IIIs (III,IIId,IIIp,IIIsi) compress (modes 2&3) */
--- 370,378 ----
int num_copies)
{
+ char init[80];
+
+ hpjet_make_init(pdev, init, "\033*r0F\033*b2M");
return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
! 300, PCL_LJ2p_FEATURES, init);
}
/* All LaserJet series IIIs (III,IIId,IIIp,IIIsi) compress (modes 2&3) */
***************
*** 331,337 ****
int num_copies)
{
return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
! 300, PCL_LJ3_FEATURES,
! "\033&l-180u36Z\033*r0F");
}
/* LaserJet IIId is same as LaserJet III, except for duplex */
--- 382,390 ----
int num_copies)
{
+ char init[80];
+
+ hpjet_make_init(pdev, init, "\033&l-180u36Z\033*r0F");
return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
! 300, PCL_LJ3_FEATURES, init);
}
/* LaserJet IIId is same as LaserJet III, except for duplex */
***************
*** 340,346 ****
int num_copies)
{
return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
! 300, PCL_LJ3D_FEATURES,
! "\033&l-180u36Z\033*r0F");
}
/* LaserJet 4 series compresses, and it needs a special sequence to */
--- 393,401 ----
int num_copies)
{
+ char init[80];
+
+ hpjet_make_init(pdev, init, "\033&l-180u36Z\033*r0F");
return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
! 300, PCL_LJ3D_FEATURES, init);
}
/* LaserJet 4 series compresses, and it needs a special sequence to */
***************
*** 352,361 ****
{
int dots_per_inch = (int)pdev->y_pixels_per_inch;
! char real_init[60];
! sprintf(real_init, "\033&l-180u36Z\033*r0F\033&u%dD", dots_per_inch);
return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
dots_per_inch, PCL_LJ4_FEATURES,
! real_init);
}
private int
--- 407,418 ----
{
int dots_per_inch = (int)pdev->y_pixels_per_inch;
! char base_init[60];
! char init[80];
! sprintf(base_init, "\033&l-180u36Z\033*r0F\033&u%dD", dots_per_inch);
! hpjet_make_init(pdev, init, base_init);
return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
dots_per_inch, PCL_LJ4_FEATURES,
! init);
}
private int
***************
*** 364,373 ****
{
int dots_per_inch = (int)pdev->y_pixels_per_inch;
! char real_init[60];
! sprintf(real_init, "\033&l-180u36Z\033*r0F\033&u%dD", dots_per_inch);
return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
dots_per_inch, PCL_LJ4D_FEATURES,
! real_init);
}
/* The 2563B line printer can't compress */
--- 421,432 ----
{
int dots_per_inch = (int)pdev->y_pixels_per_inch;
! char base_init[60];
! char init[80];
! sprintf(base_init, "\033&l-180u36Z\033*r0F\033&u%dD", dots_per_inch);
! hpjet_make_init(pdev, init, base_init);
return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
dots_per_inch, PCL_LJ4D_FEATURES,
! init);
}
/* The 2563B line printer can't compress */
***************
*** 377,383 ****
int num_copies)
{
return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
! 300, PCL_LP2563B_FEATURES,
! "\033*b0M");
}
/* The Oce line printer has TIFF compression */
--- 436,444 ----
int num_copies)
{
+ char init[80];
+
+ hpjet_make_init(pdev, init, "\033*b0M");
return dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
! 300, PCL_LP2563B_FEATURES, init);
}
/* The Oce line printer has TIFF compression */
***************
*** 388,391 ****
--- 449,453 ----
{
int code;
+ char init[80];
/* Switch to HP_RTL. */
***************
*** 395,401 ****
fputs("\033%1A", prn_stream); /* Enter PCL mode */
code = dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
! 400, PCL_OCE9050_FEATURES,
! "\033*b3M");
/* Return to HPGL/2 mode. */
--- 457,464 ----
fputs("\033%1A", prn_stream); /* Enter PCL mode */
+ hpjet_make_init(pdev, init, "\033*b0M");
+
code = dljet_mono_print_page_copies(pdev, prn_stream, num_copies,
! 400, PCL_OCE9050_FEATURES, init);
/* Return to HPGL/2 mode. */
***************
*** 409,410 ****
--- 472,523 ----
return code;
}
+
+ private int
+ hpjet_get_params(gx_device *pdev, gs_param_list *plist)
+ {
+ gx_device_hpjet *dev = (gx_device_hpjet *)pdev;
+ int code = gdev_prn_get_params(dev, plist);
+
+ if (code >= 0)
+ code = param_write_bool(plist, "ManualFeed", &dev->ManualFeed);
+ return code;
+ }
+
+ private int
+ hpjet_put_params(gx_device *pdev, gs_param_list *plist)
+ {
+ gx_device_hpjet *dev = (gx_device_hpjet *)pdev;
+ int code;
+ bool ManualFeed;
+ bool ManualFeed_set = false;
+ int MediaPosition;
+ bool MediaPosition_set = false;
+
+ code = param_read_bool(plist, "ManualFeed", &ManualFeed);
+ if (code == 0) ManualFeed_set = true;
+ if (code >= 0) {
+ code = param_read_int(plist, "%MediaSource", &MediaPosition);
+ if (code == 0) MediaPosition_set = true;
+ else if (code < 0) {
+ if (param_read_null(plist, "%MediaSource") == 0) {
+ code = 0;
+ }
+ }
+ }
+
+ if (code >= 0)
+ code = gdev_prn_put_params(pdev, plist);
+
+ if (code >= 0) {
+ if (ManualFeed_set) {
+ dev->ManualFeed = ManualFeed;
+ dev->ManualFeed_set = true;
+ }
+ if (MediaPosition_set) {
+ dev->MediaPosition = MediaPosition;
+ dev->MediaPosition_set = true;
+ }
+ }
+
+ return code;
+ }
Index: src/zmedia2.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/zmedia2.c,v
retrieving revision 1.17
diff -C2 -r1.17 zmedia2.c
*** src/zmedia2.c 13 Feb 2005 21:31:07 -0000 1.17
--- src/zmedia2.c 31 Mar 2005 20:34:10 -0000
***************
*** 56,59 ****
--- 56,60 ----
int policy_default;
float best_mismatch = (float)max_long; /* adhoc */
+ float mepos_penalty;
float mbest = best_mismatch;
match_record_t match;
***************
*** 121,126 ****
if (r_has_type(&aelt.dict, t_dictionary) &&
r_has_attr(dict_access_ref(&aelt.dict), a_read) &&
! r_has_type(&aelt.key, t_integer) &&
! (mepos < 0 || aelt.key.value.intval == mepos)
) {
bool match_all;
--- 122,126 ----
if (r_has_type(&aelt.dict, t_dictionary) &&
r_has_attr(dict_access_ref(&aelt.dict), a_read) &&
! r_has_type(&aelt.key, t_integer)
) {
bool match_all;
***************
*** 180,183 ****
--- 180,187 ----
goto no;
}
+
+ mepos_penalty = (mepos < 0 || aelt.key.value.intval == mepos) ?
+ 0 : .001;
+
/* We have a match. Save the match in case no better match is found */
if (r_has_type(&match.match_key, t_null))
***************
*** 188,198 ****
* to the current only if the key value is lower.
*/
! if (best_mismatch <= mbest) {
! if (best_mismatch < mbest ||
(r_has_type(&match.match_key, t_integer) &&
match.match_key.value.intval > aelt.key.value.intval)) {
reset_match(&match);
match.match_key = aelt.key;
! mbest = best_mismatch;
}
}
--- 192,202 ----
* to the current only if the key value is lower.
*/
! if (best_mismatch + mepos_penalty <= mbest) {
! if (best_mismatch + mepos_penalty < mbest ||
(r_has_type(&match.match_key, t_integer) &&
match.match_key.value.intval > aelt.key.value.intval)) {
reset_match(&match);
match.match_key = aelt.key;
! mbest = best_mismatch + mepos_penalty;
}
}