Matthew White <[email protected]> writes: > +/* > + Remove the quotation surrounding a string. > + > + The string is permanently modified. > + */ > +void > +dequote_metalink_string (char **str) > +{ > + char *new, *beg, *end; > + size_t str_len, new_len; > + > + if (!str || !*str) > + return; > + > + str_len = strlen (*str); /* current string length */ > + > + if (str_len < 2) > + return; > + > + new_len = str_len - 2; /* predict dequoted length */ > + > + beg = *str; /* begin of current string */ > + end = *str + (str_len - 1); /* end of current string */ > + > + /* Verify if the current string is surrounded by quotes. */ > + if (!(*beg == '\"' && *end == '\"') && !(*beg == '\'' && *end == '\'')) > + return;
could we just verify that (*str[0] == '\"' || *str[0] == '\'') and in case return before computing the strlen? Giuseppe
