// File: /workspace/github_cpp_makefile_star2_O1/nompelis[P]INTecplotLib/intecplot.cpp
// Function: inTec_File::ParseComponent_Text()
int inTec_File::ParseComponent_Text()
{
#ifdef _DEBUG_
   printf(" i Inside \"ParseComponent_Text()\" \n");
#endif

   // seek back to the begining of the line that got us here so we can re-parse
   int iret = fseek( fp, ipos, SEEK_SET );
   if( iret != 0 ) {
      printf(" e Error seeking to proper parsing position: %ld \n", ipos);
      return( iret );
   }
   // retract line-number as the line will be re-read
   --iline;

   // Looking to parse multiple keywords and possibly over multiple lines
   // T= <string>
   // ZN= <zone to associate the string>
   // X=
   // Y=
   // Z=
   // R=



   // The idea here is to keep ingesting in lines until we find a new component
   // We ingest comments that can interrupt the text component
   // Once a new component is detected, we wrap up the process

   char *field=NULL;
   size_t ifield_size=0,ifield_pos=0;

   char *buf=NULL;
   size_t ibuf_size=0;

   int idone_text = 0;   // flag for present text component termination
   while( !feof( fp ) && idone_text <= 1 ) {
      int ic;

      // information about the position in the file
      ipos = ftell( fp );
#ifdef _DEBUG_
      printf(" i Position in file at %ld bytes, line %ld \n", ipos, iline+1 );
#endif

      // prepare the buffer
      memset( buf, '\0', ibuf_size );
      // read a line of data; get count of bytes read
      ic = inUtils_ReadTextline( &ibuf_size, &buf, fp );
      // check error code

      // sanitize the line
      inUtils_TrimLeadingSpaceTextline( buf );
      size_t isize=0;
      while( isize < ibuf_size && buf[isize] != '\n' ) ++isize;
      if( buf[isize] == '\n' ) buf[isize] = '\0';
#ifdef _DEBUG3_
      printf("STRING (%p, %ld):%s\n", buf, isize, buf );
#endif

      // attempt to identify this line as a new component to terminate parsing
      int iparse_line=1;    // default is to parse the line
      iret = IdentifyComponent( buf );
#ifdef _DEBUG3_
printf("FOUND iret=%d idone_text=%d \n", iret,idone_text);
#endif
      // check if we have jumped to a new component under certain conditions...
      if( iret > 0 ) {             // we found a component
         // only allow "stray" comment components to pass through
         if( iret == Comment ) {
#ifdef _DEBUG_
            printf(" --- Found comment (inside Text component) \n");
#endif
            ++iline;
            // we will not be parsing this line
            iparse_line = 0;
            // store comment in strings
            buf[ strlen(buf) ] = '\n';
            strings[ iline ] = buf;
#ifdef _DEBUG_
            printf(" i Added comment to strings line %ld \n", iline );
#endif
            // show the line
            printf(" [%ld]  %s", iline, buf );
         } else {
#ifdef _DEBUG2_
            printf(" --- Found component (at _or_ after Text component) \n");
#endif
            // increment termination condition variable
            ++idone_text;
            // will not parse new components
            if( idone_text > 1) iparse_line = 0;
         }
      } else {
#ifdef _DEBUG2_
         printf(" --- The line is part of the Text component \n");
#endif
        iparse_line = 1;
      }

      // parse the line only if we are still parsing the current text field
      if( iparse_line == 1 ) {
         ++iline;

         // keep enlarging the "field" block
         ifield_size += isize;
         char *tmpf = (char *) realloc(field, (ifield_size+1)*sizeof(char));
         if( tmpf == NULL ) {
            free( field );
            free( buf );
            return(-2);
         }
         field = tmpf;
         tmpf = &( field[ifield_pos] );
         memset(tmpf, '\0', isize+1);
         for(size_t n=0;n<isize;++n) field[ ifield_pos + n ] = buf[n];
         ifield_pos = ifield_size;
         field[ ifield_pos ] = '\0';

#ifdef _DEBUG2_
         printf(" --- The field so far: |%s|\n", field);
#endif
      }
   }

   // drop the buffer
   free( buf );


   // set all parameters of the text component


   // drop the text storage
   free( field );


   // seek back to the begining of this line and terminate this operation
   iret = fseek( fp, ipos, SEEK_SET );
   if( iret != 0 ) {
      printf(" e Error seeking to proper parsing position: %ld \n", ipos);
      return(2);
   }


#ifdef _DEBUG_
   printf(" i *** Skipping storing of TEXT component *** \n");
   // we do this by returning control to the main parsing loop
#endif

   return(0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
leaq 0x419b(%rip), %rdi      # 0xf9bb
callq 0x5580
movq 0x110(%rbx), %rdi
movq 0x128(%rbx), %rsi
xorl %r14d, %r14d
xorl %edx, %edx
callq 0x53d0
testl %eax, %eax
je 0xb85d
movl %eax, %ebp
movq 0x128(%rbx), %rsi
leaq 0x3563(%rip), %rdi      # 0xedb4
xorl %eax, %eax
callq 0x5060
jmp 0xbb2c
decq 0x120(%rbx)
leaq 0x8(%rsp), %rax
movq %r14, (%rax)
leaq 0x20(%rsp), %rax
movq %r14, (%rax)
leaq 0x130(%rbx), %rax
movq %rax, 0x30(%rsp)
movq $0x0, 0x18(%rsp)
xorl %ebp, %ebp
movq $0x0, 0x28(%rsp)
xorl %r12d, %r12d
movq 0x110(%rbx), %rdi
callq 0x55a0
testl %eax, %eax
jne 0xbad5
cmpl $0x1, %r12d
jg 0xbad5
movq 0x110(%rbx), %rdi
callq 0x5030
movq %rax, 0x128(%rbx)
movq 0x120(%rbx), %rdx
incq %rdx
leaq 0x3613(%rip), %rdi      # 0xeeec
movq %rax, %rsi
xorl %eax, %eax
callq 0x5060
movq 0x8(%rsp), %rdi
movq 0x20(%rsp), %rdx
xorl %esi, %esi
callq 0x51e0
movq 0x110(%rbx), %rdx
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x5190
movq 0x8(%rsp), %rdi
callq 0x5050
movq 0x20(%rsp), %rax
testq %rax, %rax
je 0xb93a
movq 0x8(%rsp), %rcx
xorl %r13d, %r13d
cmpb $0xa, (%rcx,%r13)
je 0xb93d
incq %r13
cmpq %r13, %rax
jne 0xb926
movq %rax, %r13
jmp 0xb93d
xorl %r13d, %r13d
movq 0x8(%rsp), %rax
cmpb $0xa, (%rax,%r13)
jne 0xb94e
movb $0x0, (%rax,%r13)
movq 0x8(%rsp), %rsi
callq 0x5400
movb $0x1, %r15b
testl %eax, %eax
jle 0xba1b
cmpl $0x64, %eax
jne 0xba20
leaq 0x409a(%rip), %rdi      # 0xfa0d
callq 0x5580
incq 0x120(%rbx)
movq %r12, 0x10(%rsp)
movq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x5150
movb $0xa, (%r12,%rax)
movq 0x8(%rsp), %r12
movq 0x120(%rbx), %rax
movq %rax, 0x40(%rsp)
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x5570
movq %rax, %r15
movq 0x8(%rax), %rax
movq %rax, 0x38(%rsp)
movq %r12, %rdi
callq 0x5150
xorl %r14d, %r14d
movq %r15, %rdi
xorl %esi, %esi
movq 0x38(%rsp), %rdx
movq %r12, %rcx
movq 0x10(%rsp), %r12
movq %rax, %r8
callq 0x5590
movq 0x120(%rbx), %rsi
leaq 0x3428(%rip), %rdi      # 0xee1d
xorl %eax, %eax
callq 0x5060
movq 0x120(%rbx), %rsi
movq 0x8(%rsp), %rdx
leaq 0x3347(%rip), %rdi      # 0xed56
xorl %eax, %eax
callq 0x5060
movb $0x1, %r15b
jmp 0xba2f
movb $0x1, %r14b
jmp 0xba2f
testl %r12d, %r12d
leal 0x1(%r12), %eax
setle %r14b
movl %eax, %r12d
testb %r14b, %r14b
je 0xbaa6
movq %r12, 0x10(%rsp)
incq 0x120(%rbx)
movq %r13, %r14
addq %rbp, %r14
leaq 0x1(,%rbp), %rsi
addq %r13, %rsi
movq 0x18(%rsp), %rbp
movq %rbp, %rdi
callq 0x5610
testq %rax, %rax
setne %r15b
je 0xbaab
movq %rax, %r12
movq 0x28(%rsp), %rbp
addq %rax, %rbp
leaq 0x1(%r13), %rdx
movq %rbp, %rdi
xorl %esi, %esi
callq 0x51e0
testq %r13, %r13
je 0xba95
movq 0x8(%rsp), %rsi
movq %rbp, %rdi
movq %r13, %rdx
callq 0x52f0
movb $0x0, (%r12,%r14)
movq %r12, 0x18(%rsp)
movq %r14, 0x28(%rsp)
jmp 0xbabd
movq %rbp, %r14
jmp 0xbac2
movq %rbp, %rdi
callq 0x5430
movq 0x8(%rsp), %rdi
callq 0x5430
movq 0x10(%rsp), %r12
movq %r14, %rbp
testb %r15b, %r15b
jne 0xb897
movl $0xfffffffe, %ebp       # imm = 0xFFFFFFFE
jmp 0xbb2c
movq 0x8(%rsp), %rdi
callq 0x5430
movq 0x18(%rsp), %rdi
callq 0x5430
movq 0x110(%rbx), %rdi
movq 0x128(%rbx), %rsi
xorl %ebp, %ebp
xorl %edx, %edx
callq 0x53d0
testl %eax, %eax
je 0xbb20
movq 0x128(%rbx), %rsi
leaq 0x32a2(%rip), %rdi      # 0xedb4
xorl %eax, %eax
callq 0x5060
movl $0x2, %ebp
jmp 0xbb2c
leaq 0x3eb7(%rip), %rdi      # 0xf9de
callq 0x5580
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop