static bool parseDescriptors(const String& attribute, Vector<DescriptorToken>& descriptors, DescriptorParsingResult& result) { // FIXME: See if StringView can't be extended to replace DescriptorToken here. if (attribute.is8Bit()) { return parseDescriptors(attribute.characters8(), descriptors, result); } return parseDescriptors(attribute.characters16(), descriptors, result); }
// Die infos aus dem Puffer holen void SIsectionEIT::parse(void) { // printf("parse\n"); if(!buffer || parsed) return; if(bufferLength<sizeof(SI_section_EIT_header)+sizeof(struct eit_event)) { delete [] buffer; buffer=0; bufferLength=0; return; } const char *actPos=buffer+sizeof(SI_section_EIT_header); while(actPos<buffer+bufferLength-sizeof(struct eit_event)) { struct eit_event *evt=(struct eit_event *)actPos; SIevent e(evt); e.serviceID=serviceID(); e.originalNetworkID=originalNetworkID(); // printf("actpos: %p buf+bl: %p evtid: %hu desclen: %hu\n", actPos, buffer+bufferLength, evt->event_id, evt->descriptors_loop_length); // printf("maxlen: %u (%s)\n", min((unsigned)(buffer+bufferLength-actPos), evt->descriptors_loop_length), (unsigned)(buffer+bufferLength-actPos)< evt->descriptors_loop_length ? "bufferLength" : "descriptor_loop_length"); parseDescriptors(((const char *)evt)+sizeof(struct eit_event), min((unsigned)(buffer+bufferLength-actPos), evt->descriptors_loop_length), e); //printf("lds: %d\n", e.linkage_descs.size()); evts.insert(e); actPos+=sizeof(struct eit_event)+evt->descriptors_loop_length; } parsed=1; }
static void parseImageCandidatesFromSrcsetAttribute(const String& attribute, const CharType* attributeStart, unsigned length, Vector<ImageCandidate>& imageCandidates, Document* document) { const CharType* position = attributeStart; const CharType* attributeEnd = position + length; while (position < attributeEnd) { // 4. Splitting loop: Collect a sequence of characters that are space characters or U+002C COMMA characters. skipWhile<CharType, isHTMLSpaceOrComma<CharType>>(position, attributeEnd); if (position == attributeEnd) { // Contrary to spec language - descriptor parsing happens on each candidate, so when we reach the attributeEnd, we can exit. break; } const CharType* imageURLStart = position; // 6. Collect a sequence of characters that are not space characters, and let that be url. skipUntil<CharType, isHTMLSpace<CharType>>(position, attributeEnd); const CharType* imageURLEnd = position; DescriptorParsingResult result; // 8. If url ends with a U+002C COMMA character (,) if (isComma(*(position - 1))) { // Remove all trailing U+002C COMMA characters from url. imageURLEnd = position - 1; reverseSkipWhile<CharType, isComma>(imageURLEnd, imageURLStart); ++imageURLEnd; // If url is empty, then jump to the step labeled splitting loop. if (imageURLStart == imageURLEnd) continue; } else { skipWhile<CharType, isHTMLSpace<CharType>>(position, attributeEnd); Vector<DescriptorToken> descriptorTokens; tokenizeDescriptors(attributeStart, position, attributeEnd, descriptorTokens); // Contrary to spec language - descriptor parsing happens on each candidate. // This is a black-box equivalent, to avoid storing descriptor lists for each candidate. if (!parseDescriptors(attribute, descriptorTokens, result, document)) { if (document) { UseCounter::count(document, UseCounter::SrcsetDroppedCandidate); if (document->frame()) document->frame()->console().addMessage(ConsoleMessage::create(OtherMessageSource, ErrorMessageLevel, String("Dropped srcset candidate ") + String(imageURLStart, imageURLEnd - imageURLStart))); } continue; } } ASSERT(imageURLEnd > attributeStart); unsigned imageURLStartingPosition = imageURLStart - attributeStart; ASSERT(imageURLEnd > imageURLStart); unsigned imageURLLength = imageURLEnd - imageURLStart; imageCandidates.append(ImageCandidate(attribute, imageURLStartingPosition, imageURLLength, result, ImageCandidate::SrcsetOrigin)); // 11. Return to the step labeled splitting loop. } }
static Vector<ImageCandidate> parseImageCandidatesFromSrcsetAttribute(const CharType* attributeStart, unsigned length) { Vector<ImageCandidate> imageCandidates; const CharType* attributeEnd = attributeStart + length; for (const CharType* position = attributeStart; position < attributeEnd;) { // 4. Splitting loop: Collect a sequence of characters that are space characters or U+002C COMMA characters. skipWhile<CharType, isHTMLSpaceOrComma<CharType> >(position, attributeEnd); if (position == attributeEnd) { // Contrary to spec language - descriptor parsing happens on each candidate, so when we reach the attributeEnd, we can exit. break; } const CharType* imageURLStart = position; // 6. Collect a sequence of characters that are not space characters, and let that be url. skipUntil<CharType, isHTMLSpace<CharType> >(position, attributeEnd); const CharType* imageURLEnd = position; DescriptorParsingResult result; // 8. If url ends with a U+002C COMMA character (,) if (isComma(*(position - 1))) { // Remove all trailing U+002C COMMA characters from url. imageURLEnd = position - 1; reverseSkipWhile<CharType, isComma>(imageURLEnd, imageURLStart); ++imageURLEnd; // If url is empty, then jump to the step labeled splitting loop. if (imageURLStart == imageURLEnd) continue; } else { // Advancing position here (contrary to spec) to avoid an useless extra state machine step. // Filed a spec bug: https://github.com/ResponsiveImagesCG/picture-element/issues/189 ++position; Vector<StringView> descriptorTokens; tokenizeDescriptors(position, attributeEnd, descriptorTokens); // Contrary to spec language - descriptor parsing happens on each candidate. // This is a black-box equivalent, to avoid storing descriptor lists for each candidate. if (!parseDescriptors(descriptorTokens, result)) continue; } ASSERT(imageURLEnd > imageURLStart); unsigned imageURLLength = imageURLEnd - imageURLStart; imageCandidates.append(ImageCandidate(StringView(imageURLStart, imageURLLength), result, ImageCandidate::SrcsetOrigin)); // 11. Return to the step labeled splitting loop. } return imageCandidates; }
// Die infos aus dem Puffer holen void SIsectionSDT::parse(void) { // printf("parse\n"); // saveBufferToFile("sdt.sec"); // printf("Size: %d\n", sizeof(SI_section_SDT_header)); if(!buffer || bufferLength<sizeof(SI_section_SDT_header)+sizeof(struct sdt_service) || parsed) return; const char *actPos=buffer+sizeof(SI_section_SDT_header); while(actPos<=buffer+bufferLength-sizeof(struct sdt_service)) { struct sdt_service *sv=(struct sdt_service *)actPos; SIservice s(sv); s.originalNetworkID=originalNetworkID(); // printf("actpos: %p buf+bl: %p sid: %hu desclen: %hu\n", actPos, buffer+bufferLength, sv->service_id, sv->descriptors_loop_length); parseDescriptors(((const char *)sv)+sizeof(struct sdt_service), sv->descriptors_loop_length, s); svs.insert(s); actPos+=sizeof(struct sdt_service)+sv->descriptors_loop_length; } parsed=1; }