diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2019-12-02 22:53:26 -0800 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2019-12-02 22:53:26 -0800 |
commit | d1462693cfc83886e390a1612d98bc2c96e0d639 (patch) | |
tree | b956b54029763c092cca2f8411c3bc19f85810a5 | |
parent | 235176d8fb64232d675ca84239f18d810e5c37f7 (diff) | |
download | abc-d1462693cfc83886e390a1612d98bc2c96e0d639.tar.gz abc-d1462693cfc83886e390a1612d98bc2c96e0d639.tar.bz2 abc-d1462693cfc83886e390a1612d98bc2c96e0d639.zip |
Updates to JSON parser.
-rw-r--r-- | src/base/io/ioJson.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/base/io/ioJson.c b/src/base/io/ioJson.c index 14e3bfc4..3595f027 100644 --- a/src/base/io/ioJson.c +++ b/src/base/io/ioJson.c @@ -289,6 +289,21 @@ void Json_Write( char * pFileName, Abc_Nam_t * pStr, Vec_Wec_t * vObjs ) SeeAlso [] ***********************************************************************/ +char * Json_ReadPreprocess( char * pIn, int nFileSize ) +{ + char * pOut = ABC_ALLOC( char, 3*nFileSize ); int i, k = 0; + for ( i = 0; i < nFileSize; i++ ) + if ( pIn[i] == '{' || pIn[i] == '}' || pIn[i] == '[' || pIn[i] == ']' ) + { + pOut[k++] = ' '; + pOut[k++] = pIn[i]; + pOut[k++] = ' '; + } + else + pOut[k++] = pIn[i]; + pOut[k++] = '\0'; + return pOut; +} Vec_Wec_t * Json_Read( char * pFileName, Abc_Nam_t ** ppStrs ) { Abc_Nam_t * pStrs; @@ -311,6 +326,11 @@ Vec_Wec_t * Json_Read( char * pFileName, Abc_Nam_t ** ppStrs ) pContents[nFileSize] = 0; fclose( pFile ); + pContents = Json_ReadPreprocess( pCur = pContents, nFileSize ); + nFileSize = strlen(pContents); + ABC_FREE( pCur ); + pCur = pContents; + // start data-structures vObjs = Vec_WecAlloc( 1000 ); vStack = Vec_IntAlloc( 100 ); |