73a2c6c9a7
Currently, the common prefix and suffix can end up being larger than one of the two strings, if the other string has extra content that matches the portion in the overlap. For example, in JSON output, there might be a missing } in a run of consecutive }s when closing JSON outputs. (Or, more likely thanks to our infrastructure for generating JSON outputs, that the expected string has an extra }.) In this case, the returned mismatches are empty, making it hard to discern what went wrong. This CL fixes that by limiting the common suffix to be no larger than the portion of the smaller string after the common prefix. Also add handling in the case where the two strings are equal (here, returning the escaped string in the prefix and leaving the other outputs empty), though this shouldn't happen since this function is only called when the null-terminated strings are not equal. TEST=ci (manual testing on while working on CL 450381) Change-Id: I52140f32bd44d7e31cf6ba97d862a89ac0568f02 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499221 Reviewed-by: Alexander Markov <alexmarkov@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>