From 9d09f583b6ea1181ebd5af1654acd3432c427445 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Tue, 10 Jun 2008 08:01:00 -0700 Subject: Version abc80610 --- src/map/mio/mioRead.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'src/map/mio/mioRead.c') diff --git a/src/map/mio/mioRead.c b/src/map/mio/mioRead.c index 13c2cdcd..dc665050 100644 --- a/src/map/mio/mioRead.c +++ b/src/map/mio/mioRead.c @@ -265,7 +265,7 @@ Mio_Gate_t * Mio_LibraryReadGate( char ** ppToken, bool fExtendedFormat ) // then rest of the expression pToken = strtok( NULL, ";" ); - pGate->pForm = Extra_UtilStrsav( pToken ); + pGate->pForm = chomp( pToken ); // read the pin info // start the linked list of pins @@ -392,21 +392,27 @@ Mio_Pin_t * Mio_LibraryReadPin( char ** ppToken, bool fExtendedFormat ) SeeAlso [] ***********************************************************************/ -char *chomp( char *s ) +char * chomp( char *s ) { - char *b = ALLOC(char, strlen(s)+1), *c = b; - while (*s && isspace(*s)) - ++s; - while (*s && !isspace(*s)) - *c++ = *s++; - *c = 0; - return b; + char *a, *b, *c; + // remove leading spaces + for ( b = s; *b; b++ ) + if ( !isspace(*b) ) + break; + // strsav the string + a = strcpy( ALLOC(char, strlen(b)+1), b ); + // remove trailing spaces + for ( c = a+strlen(a); c > a; c-- ) + if ( *c == 0 || isspace(*c) ) + *c = 0; + else + break; + return a; } /**Function************************************************************* - Synopsis [Duplicates string and returns it with leading and - trailing spaces removed.] + Synopsis [] Description [] -- cgit v1.2.3