summaryrefslogtreecommitdiffstats
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/amap/amapRead.c66
-rw-r--r--src/map/amap/amapUniq.c7
-rw-r--r--src/map/mio/mioRead.c61
3 files changed, 77 insertions, 57 deletions
diff --git a/src/map/amap/amapRead.c b/src/map/amap/amapRead.c
index 3ccfc011..9e6ee21c 100644
--- a/src/map/amap/amapRead.c
+++ b/src/map/amap/amapRead.c
@@ -126,41 +126,52 @@ void Amap_RemoveComments( char * pBuffer, int * pnDots, int * pnLines )
// (in the BLIF file, comments are lines starting with "#")
nDots = nLines = 0;
for ( pCur = pBuffer; *pCur; pCur++ )
- {
+ {
// if this is the beginning of comment
// clean it with spaces until the new line statement
- if ( *pCur == '#' )
- while ( *pCur != '\n' )
- *pCur++ = ' ';
-
+ if ( *pCur == '#' ) {
+ while ( *pCur != '\n' ) {
+ *pCur++ = ' ';
+ }
+ }
// count the number of new lines and dots
if ( *pCur == '\n' ) {
- if (*(pCur-1)=='\r') {
- // DOS(R) file support
- if (*(pCur-2)!='\\') nLines++;
- else {
- // rewind to backslash and overwrite with a space
- *(pCur-2) = ' ';
- *(pCur-1) = ' ';
- *pCur = ' ';
- }
- } else {
- // UNIX(TM) file support
- if (*(pCur-1)!='\\') nLines++;
- else {
- // rewind to backslash and overwrite with a space
- *(pCur-1) = ' ';
- *pCur = ' ';
+ if (pCur > pBuffer) {
+ if (*(pCur - 1) == '\r') {
+ // DOS(R) file support
+ if (pCur > (pBuffer + 1)) {
+ if (*(pCur - 2)!='\\') {
+ nLines++;
+ }
+ else {
+ // rewind to backslash and overwrite with a space
+ *(pCur - 2) = ' ';
+ *(pCur - 1) = ' ';
+ *pCur = ' ';
+ }
+ }
+ } else {
+ // UNIX(TM) file support
+ if (*(pCur - 1) != '\\') {
+ nLines++;
+ }
+ else {
+ // rewind to backslash and overwrite with a space
+ *(pCur-1) = ' ';
+ *pCur = ' ';
+ }
+ }
+ }
}
+ else if ( *pCur == '.' ) {
+ nDots++;
}
- }
- else if ( *pCur == '.' )
- nDots++;
- }
+ }
+
if ( pnDots )
- *pnDots = nDots;
+ *pnDots = nDots;
if ( pnLines )
- *pnLines = nLines;
+ *pnLines = nLines;
}
/**Function*************************************************************
@@ -491,4 +502,3 @@ Amap_Lib_t * Amap_LibReadFile( char * pFileName, int fVerbose )
ABC_NAMESPACE_IMPL_END
-
diff --git a/src/map/amap/amapUniq.c b/src/map/amap/amapUniq.c
index dd858c96..e2be4343 100644
--- a/src/map/amap/amapUniq.c
+++ b/src/map/amap/amapUniq.c
@@ -278,15 +278,14 @@ Abc_Lit2Var(iFan2), (Abc_LitIsCompl(iFan2)?'-':'+') );
int ** Amap_LibLookupTableAlloc( Vec_Ptr_t * vVec, int fVerbose )
{
Vec_Int_t * vOne;
- int ** pRes, * pBuffer;
+ int ** pRes;
int i, k, nTotal, nSize, nEntries, Value;
// count the total size
nEntries = nSize = Vec_PtrSize( vVec );
Vec_PtrForEachEntry( Vec_Int_t *, vVec, vOne, i )
nEntries += Vec_IntSize(vOne);
- pBuffer = ABC_ALLOC( int, nSize * sizeof(void *) + nEntries );
- pRes = (int **)pBuffer;
- pRes[0] = pBuffer + nSize * sizeof(void *);
+ pRes = (int **)ABC_ALLOC( char, nSize * sizeof(void *) + nEntries * sizeof(int) );
+ pRes[0] = (int *)((char *)pRes + nSize * sizeof(void *));
nTotal = 0;
Vec_PtrForEachEntry( Vec_Int_t *, vVec, vOne, i )
{
diff --git a/src/map/mio/mioRead.c b/src/map/mio/mioRead.c
index c0a83cfd..c19c07d4 100644
--- a/src/map/mio/mioRead.c
+++ b/src/map/mio/mioRead.c
@@ -734,37 +734,48 @@ void Io_ReadFileRemoveComments( char * pBuffer, int * pnDots, int * pnLines )
// (in the BLIF file, comments are lines starting with "#")
nDots = nLines = 0;
for ( pCur = pBuffer; *pCur; pCur++ )
- {
+ {
// if this is the beginning of comment
// clean it with spaces until the new line statement
- if ( *pCur == '#' )
- while ( *pCur != '\n' )
- *pCur++ = ' ';
-
+ if ( *pCur == '#' ) {
+ while ( *pCur != '\n' ) {
+ *pCur++ = ' ';
+ }
+ }
// count the number of new lines and dots
if ( *pCur == '\n' ) {
- if (*(pCur-1)=='\r') {
- // DOS(R) file support
- if (*(pCur-2)!='\\') nLines++;
- else {
- // rewind to backslash and overwrite with a space
- *(pCur-2) = ' ';
- *(pCur-1) = ' ';
- *pCur = ' ';
- }
- } else {
- // UNIX(TM) file support
- if (*(pCur-1)!='\\') nLines++;
- else {
- // rewind to backslash and overwrite with a space
- *(pCur-1) = ' ';
- *pCur = ' ';
+ if (pCur > pBuffer) {
+ if (*(pCur - 1) == '\r') {
+ // DOS(R) file support
+ if (pCur > (pBuffer + 1)) {
+ if (*(pCur - 2) != '\\') {
+ nLines++;
+ }
+ else {
+ // rewind to backslash and overwrite with a space
+ *(pCur - 2) = ' ';
+ *(pCur - 1) = ' ';
+ *pCur = ' ';
+ }
+ }
+ } else {
+ // UNIX(TM) file support
+ if (*(pCur - 1) != '\\') {
+ nLines++;
+ }
+ else {
+ // rewind to backslash and overwrite with a space
+ *(pCur - 1) = ' ';
+ *pCur = ' ';
+ }
+ }
+ }
}
+ else if ( *pCur == '.' ) {
+ nDots++;
}
- }
- else if ( *pCur == '.' )
- nDots++;
- }
+ }
+
if ( pnDots )
*pnDots = nDots;
if ( pnLines )