[MPlayer-dev-eng] [PATCH] fix SAMI parsing

Howard Chu hyc at highlandsun.com
Wed Jun 9 07:55:08 CEST 2010


Reimar Döffinger wrote:
> On Mon, Jun 07, 2010 at 11:47:46PM -0700, Howard Chu wrote:
> The error as I see it is that you are arguing about "converting
> integer to binary" when the real issue is strtoul.
> Arguing about strtoul behaviour without refererring to neither
> specification nor implementation is going to lead to mistakes
> like forgetting the '-' case. The point of a proof is to make
> it nearly impossible to forget any such cases.
>
>> strtoul() is specified in ANSI and a bunch of other C standards. If
>> you can't rely on its behavior on a given platform then probably
>> none of your software will work on that platform anyway.
>
> Would that much software break if an strtoul also accepted "~0" to mean
> 0xffffffff? What if locale/LC_NUMERIC is not set to C, might something
> strange happen? E.g. my man page says
> "In  locales  other than the "C" locale, other strings may be accepted.",
> could that include a different character having the meaning of '-'?
> (Note MPlayer does not support locale != "C" at least currently, so
> it is not a convincing argument, I'm just trying to show you why
> _I_ don't think there's anything obvious here).
>
> Either way it seems obvious that is a non-productive way of attacking
> our disagreement.
> You have seen my proposal.
> It IMO has at very least the advantage of being future-proof: If other
> cases are added you don't have to take care to always read as much data
> from s as you write to d, instead you just have to make sure you never write
> more that 7 values.
> This seems to me much easier to ensure.
> In addition I think the check itself is more obvious than the memchr for '-'.
> That it eliminates the need to assuming things about strtoul is also a bonus.
> Do you disagree with those? Or do you have some other reason why you prefer
> to do it the way you proposed?

+	    else if (!strncmp (s, "&#", 2)) {
+		uint32_t c;
+		uint8_t tmp;
+		q = s+2;
+		c = strtoul(q, &s, 0);
+		if (c <= 0x7fffffff) PUT_UTF8(c, tmp, *p++ = tmp;)
+		if (*s == ';') s++; }

-- 
   -- Howard Chu
   CTO, Symas Corp.           http://www.symas.com
   Director, Highland Sun     http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP  http://www.openldap.org/project/



More information about the MPlayer-dev-eng mailing list