Menu

#64 Default omit zero style when unspecified

Unstable (example)
open
nobody
None
5
2016-04-22
2016-04-22
No

The debug string in drill.c:565 says:
"Assuming leading zeros.\n"
but the value set is GERBV_OMIT_ZEROS_LEADING, the opposite. This patch changes this behaviour and set image->format->omit_zeros to GERBV_OMIT_ZEROS_TRAILING

From e80a0f3597276cf7738fb17c00e6e659175f02c1 Mon Sep 17 00:00:00 2001
From: Nicola Corna nicola@corna.info
Date: Fri, 22 Apr 2016 09:14:12 +0200
Subject: [PATCH] Fix unspecified zeros from GERBV_OMIT_ZEROS_LEADING to
GERBV_OMIT_ZEROS_TRAILING


src/drill.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/drill.c b/src/drill.c
index b4bfe95..5e846b3 100644
--- a/src/drill.c
+++ b/src/drill.c
@@ -589,7 +589,7 @@ parse_drillfile(gerb_file_t fd, gerbv_HID_Attribute attr_list, int n_attr, int
-1,
_("Assuming leading zeros."),
GERBV_MESSAGE_WARNING);
- image->format->omit_zeros = GERBV_OMIT_ZEROS_LEADING;
+ image->format->omit_zeros = GERBV_OMIT_ZEROS_TRAILING;
}
break;
case DRILL_M_METRIC :
--
2.8.0.rc3

After applying this patch on my local repo i noticed that gerbv still doesn't work with the attached test.drl file
I ran it with debug enabled and this was printed:
"[...]
read_double(): omit_zeros = 3, fmt = 0
[...]"

omit_zeros = 3 means GERBV_OMIT_ZEROS_UNSPECIFIED, therefore the "case 'M':" at drill.c:542 is never called with this file.
On drill.c:1581 the if...else comments suggest that omit_zero, at this point, should be either GERBV_OMIT_ZEROS_LEADING or GERBV_OMIT_ZEROS_TRAILING. Somehow, on test.drl, omit_zeros is left unchanged and the wrong behaviour (trailing zeros) is used. A simple fix would be to change the if in this way:
if (omit_zeros == GERBV_OMIT_ZEROS_TRAILING || omit_zeros == GERBV_OMIT_ZEROS_UNSPECIFIED)
but this does not seem a clean solution, as the only acceptable omit_zeros values at this point should be only GERBV_OMIT_ZEROS_LEADING or GERBV_OMIT_ZEROS_TRAILING

Any idea?

1 Attachments

Discussion


Log in to post a comment.