Ticket #348 (closed defect: fixed)

Opened 11 years ago

Last modified 11 years ago

Various bugs in string comparison functions

Reported by: bennylp Owned by: bennylp
Priority: normal Milestone: release-0.8.0
Component: pjlib Version: trunk
Keywords: Cc:
Backport to 1.x milestone: Backported:

Description (last modified by bennylp) (diff)

Bug in pj_strcmp2() will cause pj_strcmp2("1", "12") to return equal.

Checking other string functions reveals that some string comparison functions are not exactly compliant with ANSI. For example, given:

  char *s1 = "2";
  char *s2 = "11";

With ANSI, strcmp(s1, s2) will return 1, while with pj_strcmp(s1, s2) will return -1.

The reason why the result was different was because string comparison in PJLIB was too optimized for speed, so it only cares about the fact that the string was different.

Change History

comment:1 Changed 11 years ago by bennylp

  • Description modified (diff)

comment:2 Changed 11 years ago by bennylp

  • Status changed from new to closed
  • Resolution set to fixed

Fixed in r1397:

  • string comparisons now compliant with the ANSI behavior

Thanks Cool_Zer0 for pointing out the bug.

Note: See TracTickets for help on using tickets.