From ab7925afcc051d42a181bcfb87289b53aa37a935 Mon Sep 17 00:00:00 2001 From: Richard Barlow <richard@richardbarlow.co.uk> Date: Sat, 12 Nov 2011 01:41:47 +0000 Subject: [PATCH] Fix parsing of route styles with units A bug appeared after route styles started being saved with units suffixed. When loading a PCB file the units were ignored and therefore it was assumed the values were in cmils. This was a problem in the get_unit_struct() function which didn't handle long strings well. If the unit was followed by more characters strcmp would return non-zero. The function has already worked out the length of the unit text and therefore strncmp should be used. --- src/pcb-printf.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pcb-printf.c b/src/pcb-printf.c index c57a570..f687e06 100644 --- a/src/pcb-printf.c +++ b/src/pcb-printf.c @@ -182,10 +182,10 @@ const Unit *get_unit_struct (const char *const_suffix) } /* Do lookup */ - if (*suffix) + if (*suffix && s_len > 0) for (i = 0; i < N_UNITS; ++i) - if (strcmp (suffix, Units[i].suffix) == 0 || - strcmp (suffix, Units[i].alias[0]) == 0) + if (strncmp (suffix, Units[i].suffix, s_len) == 0 || + strncmp (suffix, Units[i].alias[0], s_len) == 0) { g_free (m_suffix); return &Units[i]; -- 1.7.4.4