Menu

#50 Fix for gerbv when there aren't enough digits

Unstable (example)
closed-duplicate
nobody
None
5
2018-04-22
2013-07-21
Mitch Davis
No

Hello,

A patch for gerbv. I was having trouble reading this file:

M71
M48
T12F00S00C5.200
%
T12
X009734Y00055
X002634
X011287Y008
X001081
M30

This file should be metric, and 4 digits, with leading zero suppression.
However, note that 00055 and 008 don't have enough digits. So gerbv reads
the values wrong. With this change, gerbv works ok.

commit 39b63014ee17cf0f2950250b2597dadcbf478524
Author: Mitch Davis mjd@hackvana.com
Date: Sun Jul 21 13:02:06 2013 +1000

If we're in 'omit trailing zeros' mode, and if a coordinate has less digits
than expected, then pad with implicit zeroes.

diff --git a/src/drill.c b/src/drill.c
index 16b3c1c..41d5eb4 100644
--- a/src/drill.c
+++ b/src/drill.c
@@ -1630,7 +1630,7 @@ read_double(gerb_file_t *fd, enum number_fmt_t fmt, gerbv_omit_zeros_t omit_zero
dprintf("%s(): wantdigits = %d, strlen(\"%s\") = %ld\n",
FUNCTION, wantdigits, temp, (long) strlen(temp));
for (i = 0 ; i < wantdigits ; i++) {
- tmp2[i] = temp[i];
+ tmp2[i] = temp[i] ? temp[i] : '0';
}
tmp2[wantdigits] = '.';
for (i = wantdigits ; i <= strlen(temp) ; i++) {

1 Attachments

Discussion

  • Bryce Nesbitt

    Bryce Nesbitt - 2016-07-10

    Useful patch! I hope it gets applied.

     
  • Sergey Alyoshin

    Sergey Alyoshin - 2018-04-22
    • status: open --> closed-duplicate
    • Attachments has changed:

    Diff:

    --- old
    +++ new
    @@ -0,0 +1 @@
    +before-and-after-b0b55e7589e4dc626e77a0bcffd134c3b212fc81.png (64.0 kB; image/png)
    
     
  • Sergey Alyoshin

    Sergey Alyoshin - 2018-04-22

    I think this is already fixed in git commit b0b55e7589e4dc626e77a0bcffd134c3b212fc81

     
  • Sergey Alyoshin

    Sergey Alyoshin - 2018-04-22

    Please see attached image
    before-and-after-b0b55e7589e4dc626e77a0bcffd134c3b212fc81.png
    showing drill file with settings before and after git commit b0b55e7589e4dc626e77a0bcffd134c3b212fc81

     

Log in to post a comment.