On Mon, Oct 15, 2007 at 08:46:15AM +0200, Andre Poenitz wrote:

> > +bool Encodings::isKnownLangChar(char_type c, string & preamble)
> > +{
> > +   CharInfoMap::const_iterator const it = unicodesymbols.find(c);
> > +   if (it != unicodesymbols.end()) {
> > +           if (it->second.preamble != "textgreek" &&
> > +               it->second.preamble != "textcyr")
> > +                   return false;
> > +           if (preamble.empty()) {
> > +                   preamble = it->second.preamble;
> > +                   return true;
> > +           }
> > +           return it->second.preamble == preamble;
> > +   }
> > +   return false;
> > +}
> 
> Please return early

Do you mean

      if (it == unicodesymbols.end())
              return false;
?

> > +int Paragraph::Pimpl::knownLangChars(odocstream & os,
> > +                                value_type c,
> > +                                string & preamble,
> > +                                Change & runningChange,
> > +                                Encoding const & encoding,
> > +                                pos_type & i)
> > +{
> > +   // The latex command is "\textLANG{<spec>}" and we have to retain
> > +   // "\textLANG{<spec>" for the first char but only "<spec>" for all
> > +   // subsequent chars (this also works when we are passed untranslated
> > +   // unicode).
> > +   docstring const latex1 = rtrim(encoding.latexChar(c), "}");
> > +   int length = latex1.length();
> > +   os << latex1;
> > +   while (i < size() - 1) {
> 
> Would that work with size() == 0? [Can that happen?]
> I'd feel more comfortable with ... + 1 < ...

Me too, but this is how it is done all over the place, so I sticked
to that. Seems that there are no ill effects. I think that size() == 0
cannot happen as a paragraph cannot be empty.

-- 
Enrico

Reply via email to