aboutsummaryrefslogtreecommitdiff
path: root/gdb/utils.c
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2011-04-27 19:52:22 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2011-04-27 19:52:22 +0000
commitb11b1f88bd8c59e136e0ec10fbf5ea7f30d0ded6 (patch)
tree0595cd7793c646c3ec2a0edeb0a44a4d07850915 /gdb/utils.c
parent8344e389dcb05ca85547b483fda3f162749c4623 (diff)
downloadbinutils-b11b1f88bd8c59e136e0ec10fbf5ea7f30d0ded6.zip
binutils-b11b1f88bd8c59e136e0ec10fbf5ea7f30d0ded6.tar.gz
binutils-b11b1f88bd8c59e136e0ec10fbf5ea7f30d0ded6.tar.bz2
gdb/
Format the code for the next patch. * dwarf2read.c (struct mapped_index): Include delimiting newlines. * utils.c (strcmp_iw_ordered): Reformat the code for the next patch. New variables c1 and c2.
Diffstat (limited to 'gdb/utils.c')
-rw-r--r--gdb/utils.c79
1 files changed, 43 insertions, 36 deletions
diff --git a/gdb/utils.c b/gdb/utils.c
index 11c34bf..850b80d 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -3023,48 +3023,55 @@ strcmp_iw (const char *string1, const char *string2)
int
strcmp_iw_ordered (const char *string1, const char *string2)
{
- while ((*string1 != '\0') && (*string2 != '\0'))
+ /* Formatting stub. */
+ if (1)
{
- while (isspace (*string1))
- {
- string1++;
- }
- while (isspace (*string2))
- {
- string2++;
- }
- if (*string1 != *string2)
+ /* C1 and C2 are valid only if *string1 != '\0' && *string2 != '\0'.
+ Provide stub characters if we are already at the end of one of the
+ strings. */
+ char c1 = 'X', c2 = 'X';
+
+ while (*string1 != '\0' && *string2 != '\0')
{
- break;
+ while (isspace (*string1))
+ string1++;
+ while (isspace (*string2))
+ string2++;
+
+ c1 = *string1;
+ c2 = *string2;
+ if (c1 != c2)
+ break;
+
+ if (*string1 != '\0')
+ {
+ string1++;
+ string2++;
+ }
}
- if (*string1 != '\0')
+
+ switch (*string1)
{
- string1++;
- string2++;
+ /* Characters are non-equal unless they're both '\0'; we want to
+ make sure we get the comparison right according to our
+ comparison in the cases where one of them is '\0' or '('. */
+ case '\0':
+ if (*string2 == '\0')
+ return 0;
+ else
+ return -1;
+ case '(':
+ if (*string2 == '\0')
+ return 1;
+ else
+ return -1;
+ default:
+ if (*string2 == '\0' || *string2 == '(')
+ return 1;
+ else
+ return c1 - c2;
}
}
-
- switch (*string1)
- {
- /* Characters are non-equal unless they're both '\0'; we want to
- make sure we get the comparison right according to our
- comparison in the cases where one of them is '\0' or '('. */
- case '\0':
- if (*string2 == '\0')
- return 0;
- else
- return -1;
- case '(':
- if (*string2 == '\0')
- return 1;
- else
- return -1;
- default:
- if (*string2 == '(')
- return 1;
- else
- return *string1 - *string2;
- }
}
/* A simple comparison function with opposite semantics to strcmp. */