@@ -2024,8 +2024,8 @@ AST* AST_parseStmt(AST* ast, char* sStmt) {
20242024
20252025static int32_t Parser_getPyLineBlockDeepth (char * sLine ) {
20262026 int32_t iSpaceNum = strGetIndent (sLine );
2027- if (0 == iSpaceNum % 4 ) {
2028- return iSpaceNum / 4 ;
2027+ if (0 == iSpaceNum % PIKA_BLOCK_SPACE ) {
2028+ return iSpaceNum / PIKA_BLOCK_SPACE ;
20292029 }
20302030 /* space Num is not 4N, error*/
20312031 return -1 ;
@@ -2708,6 +2708,11 @@ static char* Suger_import(Args* outbuffs, char* sLine) {
27082708
27092709static char * Parser_sugerProcess (Args * outbuffs , char * sLine ) {
27102710 /* process import */
2711+ int32_t block_deepth = Parser_getPyLineBlockDeepth (sLine );
2712+ if (block_deepth < 0 ) {
2713+ return NULL ;
2714+ }
2715+ sLine = sLine + block_deepth * PIKA_BLOCK_SPACE ;
27112716 sLine = Suger_import (outbuffs , sLine );
27122717 /* process multi assign */
27132718 int iLineNum = strCountSign (sLine , '\n' ) + 1 ;
@@ -2721,6 +2726,8 @@ static char* Parser_sugerProcess(Args* outbuffs, char* sLine) {
27212726 aLine = arg_strAppend (aLine , sSingleLine );
27222727 }
27232728 sLine = strsCopy (outbuffs , arg_getStr (aLine ));
2729+ sLine =
2730+ strsAddIndentation (outbuffs , sLine , block_deepth * PIKA_BLOCK_SPACE );
27242731 if (NULL != aLine ) {
27252732 arg_deinit (aLine );
27262733 }
0 commit comments