On Wed, Apr 08, 2020 at 02:39:39PM +0200, Gerd Hoffmann wrote: > > > +again: > > > + switch (ptr[offset]) { > > > + case 0: /* null name */ > > > + offset++; > > > + *(dst++) = 0; > > > + break; > [ ... ] > > > + case '^': > > > + *(dst++) = '^'; > > > + offset++; > > > + goto again; > > > > I think this code would be more clear if it used "for (;;) {" and > > "continue" instead of a backwards goto. > > Hmm, doesn't help that much due to for + switch nesting. I would need > either an additional state variable or use goto to jump from inside > switch out of the for loop. Both ways don't make things more clear > compared to the current state ...
static int parse_namestring(struct parse_state *s, u8 *ptr, const char *item) { char *dst = s->name; int offset = 0; int i, count; for (;;) { switch (ptr[offset]) { case 0: /* null name */ offset++; *(dst++) = 0; break; case 0x2e: offset++; offset += parse_nameseg(ptr + offset, &dst); *(dst++) = '.'; offset += parse_nameseg(ptr + offset, &dst); break; case 0x2f: offset++; count = ptr[offset]; offset++; for (i = 0; i < count; i++) { if (i) *(dst++) = '.'; offset += parse_nameseg(ptr + offset, &dst); } break; case '\\': *(dst++) = '\\'; offset++; continue; case '^': *(dst++) = '^'; offset++; continue; case 'A' ... 'Z': case '_': offset += parse_nameseg(ptr, &dst); break; default: hex(ptr, 16, 3, __func__); s->error = 1; break; } break; } dprintf(5, "%s: %d %s '%s'\n", __func__, s->depth, item, s->name); return offset; } -Kevin _______________________________________________ SeaBIOS mailing list -- seabios@seabios.org To unsubscribe send an email to seabios-le...@seabios.org