Block* BlockLocator_iternext(BlockLocator *self) { _BlockLocator_Callback *fn; unsigned long c = 0; Py_UNICODE *codestr_end = self->codestr + self->codestr_sz; #ifdef DEBUG fprintf(stderr, "%s\n", __PRETTY_FUNCTION__); #endif memset(&self->block, 0, sizeof(Block)); while (self->codestr_ptr < codestr_end) { c = *(self->codestr_ptr); if (c == '\n') { self->lineno++; } repeat: if (c == '\\') { /* Start of an escape sequence; ignore next character */ self->codestr_ptr++; } else if (c == '}' && self->depth == 0) { self->block.error = -1; sprintf(self->exc, "Unexpected closing brace on line %d", self->lineno); #ifdef DEBUG fprintf(stderr, "\t%s\n", self->exc); #endif } /* only ASCII is special syntactically */ else if (c < 256) { fn = scss_function_map[ (int)c + 256 * self->instr + 256 * 256 * (int)(self->par != 0) + 256 * 256 * 2 * (int)(self->depth > 1 ? 2 : self->depth) ]; if (fn != NULL) { fn(self); } } self->codestr_ptr++; if (self->codestr_ptr > codestr_end) { self->codestr_ptr = codestr_end; } if (self->block.error) { #ifdef DEBUG if (self->block.error > 0) { fprintf(stderr, "\tBlock found!\n"); } else { fprintf(stderr, "\tException!\n"); } #endif return &self->block; } } if (self->par > 0) { if (self->block.error >= 0) { self->block.error = -1; sprintf(self->exc, "Missing closing parenthesis somewhere in block"); #ifdef DEBUG fprintf(stderr, "\t%s\n", self->exc); #endif } } else if (self->instr != 0) { if (self->block.error >= 0) { self->block.error = -2; sprintf(self->exc, "Missing closing string somewhere in block"); #ifdef DEBUG fprintf(stderr, "\t%s\n", self->exc); #endif } } else if (self->depth > 0) { if (self->block.error >= 0) { self->block.error = -3; sprintf(self->exc, "Missing closing string somewhere in block"); #ifdef DEBUG fprintf(stderr, "\t%s\n", self->exc); #endif } if (self->init < codestr_end) { c = '}'; goto repeat; } } if (self->init < codestr_end) { self->init = codestr_end; c = 0; goto repeat; } BlockLocator_rewind(self); return &self->block; }
Block* BlockLocator_iternext(BlockLocator *self) { _BlockLocator_Callback *fn; unsigned char c = 0; char *codestr_end = self->codestr + self->codestr_sz; #ifdef DEBUG fprintf(stderr, "%s\n", __PRETTY_FUNCTION__); #endif memset(&self->block, 0, sizeof(Block)); while (self->codestr_ptr < codestr_end) { c = *(self->codestr_ptr); if (!c) { self->codestr_ptr++; continue; } repeat: fn = scss_function_map[ (int)c + 256 * self->instr + 256 * 256 * (int)(self->par != 0) + 256 * 256 * 2 * (int)(self->depth > 1 ? 2 : self->depth) ]; if (fn != NULL) { fn(self); } self->codestr_ptr++; if (self->codestr_ptr > codestr_end) { self->codestr_ptr = codestr_end; } if (self->block.error) { #ifdef DEBUG if (self->block.error > 0) { fprintf(stderr, "\tBlock found!\n"); } else { fprintf(stderr, "\tException!\n"); } #endif return &self->block; } } if (self->par > 0) { if (self->block.error >= 0) { self->block.error = -1; sprintf(self->exc, "Missing closing parenthesis somewhere in block"); #ifdef DEBUG fprintf(stderr, "\t%s\n", self->exc); #endif } } else if (self->instr != 0) { if (self->block.error >= 0) { self->block.error = -2; sprintf(self->exc, "Missing closing string somewhere in block"); #ifdef DEBUG fprintf(stderr, "\t%s\n", self->exc); #endif } } else if (self->depth > 0) { if (self->block.error >= 0) { self->block.error = -3; sprintf(self->exc, "Missing closing string somewhere in block"); #ifdef DEBUG fprintf(stderr, "\t%s\n", self->exc); #endif } if (self->init < codestr_end) { c = '}'; goto repeat; } } if (self->init < codestr_end) { self->init = codestr_end; c = 0; goto repeat; } BlockLocator_rewind(self); return &self->block; }