// File: gpertea[P]gclib/GStr.cpp
// Function: GStr::nextToken(GStr&)
bool GStr::nextToken(GStr& token) {
 if (fTokenDelimiter==NULL) {
    GError("GStr:: no token delimiter; use StartTokenize first\n");
    }
 if (fLastTokenStart>=length()) {//no more
    GFREE(fTokenDelimiter);
    fLastTokenStart=0;
    return false;
    }
 int dlen=strlen(fTokenDelimiter);
 char* delpos=NULL; //delimiter position
 int tlen=0;
 if (fTokenizeMode==tkFullString) { //exact string as a delimiter
   delpos=(char*)strstr(my_data->chars+fLastTokenStart,fTokenDelimiter);
   if (delpos==NULL) delpos=(char*)(my_data->chars+length());
   //empty records may be returned
   if (my_data->chars+fLastTokenStart == delpos) { //empty token
     fLastTokenStart=(delpos-my_data->chars)+dlen;
     token="";
     return true;
     }
    else {
     tlen=delpos-(my_data->chars+fLastTokenStart);
     token.prep_data(tlen);
     ::memcpy(token.chrs(), &my_data->chars[fLastTokenStart], tlen);
     fLastTokenStart=(delpos-my_data->chars)+dlen;
     return true;
     }
   }
  else { //tkCharSet - any character is a delimiter
   //empty records are never returned !
   if (fLastTokenStart==0) {//skip any starting delimiters
     delpos=(char*)my_data->chars;
     while (*delpos!='\0' && strchr(fTokenDelimiter, *delpos)!=NULL)
       delpos++;
     if (*delpos!='\0')
         fLastTokenStart = delpos-my_data->chars;
       else { //only delimiters here,no tokens
         GFREE(fTokenDelimiter);
         fLastTokenStart=0;
         return false;
         }
     }
   //now fLastTokenStart is on a non-delimiter char
   //GMessage("String at fLastTokenStart=%d is %s\n", fLastTokenStart, delpos);
   char* token_end=NULL;
   delpos=(char*)strpbrk(my_data->chars+fLastTokenStart,fTokenDelimiter);
   if (delpos==NULL) delpos=(char*)(my_data->chars+length());
   token_end=delpos-1;
   while (*delpos!='\0' && strchr(fTokenDelimiter, *delpos)!=NULL)
      delpos++; //skip any other delimiters in the set!
   //now we know that delpos is on the beginning of next token
   tlen=(token_end-my_data->chars)-fLastTokenStart+1;
   if (tlen==0) {
       GFREE(fTokenDelimiter);
       fLastTokenStart=0;
       return false;
       }
   token.prep_data(tlen);
   ::memcpy(token.chrs(), &my_data->chars[fLastTokenStart], tlen);
   fLastTokenStart=delpos-my_data->chars;
   return true;
   }
 //return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, (%rax)
jne 0xaa9c
leaq 0x9744(%rip), %rdi      # 0x141d9
movb $0x0, %al
callq 0x2640
movq -0x40(%rbp), %rdi
movl 0x8(%rdi), %eax
movl %eax, -0x44(%rbp)
callq 0xb660
movl %eax, %ecx
movl -0x44(%rbp), %eax
cmpl %ecx, %eax
jl 0xaad1
movq -0x40(%rbp), %rdi
callq 0x5a90
movq -0x40(%rbp), %rax
movl $0x0, 0x8(%rax)
movb $0x0, -0x1(%rbp)
jmp 0xadee
movq -0x40(%rbp), %rax
movq (%rax), %rdi
callq 0x2140
movq %rax, %rcx
movq -0x40(%rbp), %rax
movl %ecx, -0x1c(%rbp)
movq $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
cmpl $0x0, 0xc(%rax)
jne 0xac13
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rdi
addq $0xc, %rdi
movslq 0x8(%rax), %rcx
addq %rcx, %rdi
movq (%rax), %rsi
callq 0x2090
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xab4b
movq -0x40(%rbp), %rdi
movq 0x20(%rdi), %rax
addq $0xc, %rax
movq %rax, -0x50(%rbp)
callq 0xb660
movl %eax, %ecx
movq -0x50(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x40(%rbp), %rcx
movq 0x20(%rcx), %rax
addq $0xc, %rax
movslq 0x8(%rcx), %rcx
addq %rcx, %rax
cmpq -0x28(%rbp), %rax
jne 0xab9a
movq -0x40(%rbp), %rax
movq -0x28(%rbp), %rcx
movq 0x20(%rax), %rdx
addq $0xc, %rdx
subq %rdx, %rcx
movslq -0x1c(%rbp), %rdx
addq %rdx, %rcx
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rdi
leaq 0x9537(%rip), %rsi      # 0x140c3
callq 0x6b70
movb $0x1, -0x1(%rbp)
jmp 0xadee
movq -0x40(%rbp), %rdx
movq -0x28(%rbp), %rax
movq 0x20(%rdx), %rcx
addq $0xc, %rcx
movslq 0x8(%rdx), %rdx
addq %rdx, %rcx
subq %rcx, %rax
movl %eax, -0x2c(%rbp)
movq -0x18(%rbp), %rdi
movl -0x2c(%rbp), %esi
xorl %edx, %edx
callq 0x6260
movq -0x18(%rbp), %rdi
callq 0xb630
movq %rax, %rdi
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rsi
addq $0xc, %rsi
movslq 0x8(%rax), %rax
addq %rax, %rsi
movslq -0x2c(%rbp), %rdx
callq 0x21f0
movq -0x40(%rbp), %rax
movq -0x28(%rbp), %rcx
movq 0x20(%rax), %rdx
addq $0xc, %rdx
subq %rdx, %rcx
movslq -0x1c(%rbp), %rdx
addq %rdx, %rcx
movl %ecx, 0x8(%rax)
movb $0x1, -0x1(%rbp)
jmp 0xadee
movq -0x40(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0xacb9
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rax
addq $0xc, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x51(%rbp)
je 0xac5f
movq -0x40(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movsbl (%rax), %esi
callq 0x2100
cmpq $0x0, %rax
setne %al
movb %al, -0x51(%rbp)
movb -0x51(%rbp), %al
testb $0x1, %al
jne 0xac68
jmp 0xac76
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0xac31
movq -0x28(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0xac9a
movq -0x40(%rbp), %rax
movq -0x28(%rbp), %rcx
movq 0x20(%rax), %rdx
addq $0xc, %rdx
subq %rdx, %rcx
movl %ecx, 0x8(%rax)
jmp 0xacb7
movq -0x40(%rbp), %rdi
callq 0x5a90
movq -0x40(%rbp), %rax
movl $0x0, 0x8(%rax)
movb $0x0, -0x1(%rbp)
jmp 0xadee
jmp 0xacb9
movq -0x40(%rbp), %rax
movq $0x0, -0x38(%rbp)
movq 0x20(%rax), %rdi
addq $0xc, %rdi
movslq 0x8(%rax), %rcx
addq %rcx, %rdi
movq (%rax), %rsi
callq 0x23f0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xad0c
movq -0x40(%rbp), %rdi
movq 0x20(%rdi), %rax
addq $0xc, %rax
movq %rax, -0x60(%rbp)
callq 0xb660
movl %eax, %ecx
movq -0x60(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x61(%rbp)
je 0xad46
movq -0x40(%rbp), %rax
movq (%rax), %rdi
movq -0x28(%rbp), %rax
movsbl (%rax), %esi
callq 0x2100
cmpq $0x0, %rax
setne %al
movb %al, -0x61(%rbp)
movb -0x61(%rbp), %al
testb $0x1, %al
jne 0xad4f
jmp 0xad5d
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0xad18
movq -0x40(%rbp), %rcx
movq -0x38(%rbp), %rax
movq 0x20(%rcx), %rdx
addq $0xc, %rdx
subq %rdx, %rax
movslq 0x8(%rcx), %rcx
subq %rcx, %rax
addq $0x1, %rax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jne 0xad9e
movq -0x40(%rbp), %rdi
callq 0x5a90
movq -0x40(%rbp), %rax
movl $0x0, 0x8(%rax)
movb $0x0, -0x1(%rbp)
jmp 0xadee
movq -0x18(%rbp), %rdi
movl -0x2c(%rbp), %esi
xorl %edx, %edx
callq 0x6260
movq -0x18(%rbp), %rdi
callq 0xb630
movq %rax, %rdi
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rsi
addq $0xc, %rsi
movslq 0x8(%rax), %rax
addq %rax, %rsi
movslq -0x2c(%rbp), %rdx
callq 0x21f0
movq -0x40(%rbp), %rax
movq -0x28(%rbp), %rcx
movq 0x20(%rax), %rdx
addq $0xc, %rdx
subq %rdx, %rcx
movl %ecx, 0x8(%rax)
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax)