From 131bc65f4bf4809f65b2061a5ff29ffc9d10ea0a Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Fri, 4 Mar 2016 14:47:35 +0100 Subject: [PATCH] Generate correctly instance coordinates in GDS driver. * Bug: In gds_drive.c, the XY GDSII record for storing the instances coordinates was using two longs (8 bytes each) instead of int (4 bytes). Now use a coord_t to force them to be 32 bits integers. * Bug: In gds_parse.c, symmetric bug to the above. Read 32 bits integers for XY of instances instead of 64 bits integers. --- alliance/src/rds/src/gds_drive.c | 18 +++++++++++------- alliance/src/rds/src/gds_parse.c | 14 +++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/alliance/src/rds/src/gds_drive.c b/alliance/src/rds/src/gds_drive.c index b7106c1b..833bd8f7 100644 --- a/alliance/src/rds/src/gds_drive.c +++ b/alliance/src/rds/src/gds_drive.c @@ -490,18 +490,22 @@ FILE *fp; } entete(XY, sizeof(coord_t)); - if (islittle()) { - long X = swapl(inst->X); - long Y = swapl(inst->Y); + coord_t xy; + xy.X = inst->X; + xy.Y = inst->Y; - numb = fwrite((char *)&X, sizeof(long), 1, fp); + if (islittle()) { + xy.X = swapi(xy.X); + xy.Y = swapi(xy.Y); + + numb = fwrite((char *)&xy.X, sizeof(int32_t), 1, fp); controle(1); - numb = fwrite((char *)&Y, sizeof(long), 1, fp); + numb = fwrite((char *)&xy.Y, sizeof(int32_t), 1, fp); controle(1); } else { - numb = fwrite((char *)&inst->X, sizeof(long), 1, fp); + numb = fwrite((char *)&xy.X, sizeof(int32_t), 1, fp); controle(1); - numb = fwrite((char *)&inst->Y, sizeof(long), 1, fp); + numb = fwrite((char *)&xy.Y, sizeof(int32_t), 1, fp); controle(1); } diff --git a/alliance/src/rds/src/gds_parse.c b/alliance/src/rds/src/gds_parse.c index dfa2239b..07b0fb33 100644 --- a/alliance/src/rds/src/gds_parse.c +++ b/alliance/src/rds/src/gds_parse.c @@ -832,7 +832,7 @@ char gds_real[sizeof(mag_type)]; short ref_x_axis, abs_mag, abs_ang; ushort strans; double mag, angle; -long x, y; +int32_t x, y; char sym; char poubelle[TRASHSIZE]; int FLAG = 0; @@ -846,14 +846,14 @@ int FLAG = 0; } switch (infobuf.gdscode) { case XY : - lecture1(&x, sizeof(long)); + lecture1(&x, sizeof(int32_t)); if (islittle()) x = swapl(x); - x = (long)(pv_scale * (double)x); - lecture1(&y, sizeof(long)); + x = (int32_t)(pv_scale * (double)x); + lecture1(&y, sizeof(int32_t)); if (islittle()) y = swapl(y); - y = (long)(pv_scale * (double)y); + y = (int32_t)(pv_scale * (double)y); break; case STRANS : lecture1(&strans, sizeof(ushort)); @@ -988,8 +988,8 @@ FILE *fp; coord_tab[0].X = swapl(coord_tab[0].X); coord_tab[0].Y = swapl(coord_tab[0].Y); } - coord_tab[0].X = (long)(pv_scale * (double)coord_tab[0].X); - coord_tab[0].Y = (long)(pv_scale * (double)coord_tab[0].Y); + coord_tab[0].X = (int32_t)(pv_scale * (double)coord_tab[0].X); + coord_tab[0].Y = (int32_t)(pv_scale * (double)coord_tab[0].Y); XYFLAG = 1; break; case TEXTTYPE :