[Pinfo-devel] r137 - pinfo/branches/cxx/src
Nathanael Nerode
neroden-guest at costa.debian.org
Fri Sep 2 06:18:14 UTC 2005
Author: neroden-guest
Date: 2005-09-02 06:18:14 +0000 (Fri, 02 Sep 2005)
New Revision: 137
Modified:
pinfo/branches/cxx/src/utils.cxx
Log:
Cleanup of compare_tag_table_string.
Modified: pinfo/branches/cxx/src/utils.cxx
===================================================================
--- pinfo/branches/cxx/src/utils.cxx 2005-09-02 06:02:50 UTC (rev 136)
+++ pinfo/branches/cxx/src/utils.cxx 2005-09-02 06:18:14 UTC (rev 137)
@@ -313,29 +313,35 @@
int
compare_tag_table_string(const char *base, const char *compared)
{
- int i, j;
-
- j = 0;
-
- for (i = 0; base[i] != 0; i++)
- {
- if (base[i] != compared[j])
- {
- if ((isspace(compared[j])) &&(isspace(base[i]))); /* OK--two blanks */
- else if (isspace(compared[j]))
- i--; /* index of `base' should be unchanged after for's i++ */
- else if (isspace(base[i]))
- j--; /* index of `compared' stands in place
- and waits for base to skip blanks */
- else
- return (int) base[i] -(int) compared[j];
+ int i = 0;
+ int j = 0;
+ while (base[i] != '\0') {
+ if (base[i] != compared[j]) {
+ if (isspace(compared[j]) && isspace(base[i])) {
+ /* OK--two blanks */
+ j++;
+ i++;
+ } else if (isspace(compared[j])) {
+ /* index of `base' stands in place
+ * and waits for compared to skip blanks */
+ j++;
+ } else if (isspace(base[i])) {
+ /* index of `compared' stands in place
+ * and waits for base to skip blanks */
+ i++;
+ } else {
+ /* This catches all ordinary differences, and compared being shorter */
+ return (int) base[i] - (int) compared[j];
+ }
+ } else {
+ i++;
+ j++;
}
- j++;
}
- while (compared[j]) /* handle trailing whitespaces of variable `compared' */
- {
+ /* handle trailing whitespaces of variable `compared' */
+ while (compared[j] != '\0') {
if (!isspace(compared[j]))
- return (int) base[i] -(int) compared[j];
+ return (int) '\0' - (int) compared[j]; /* Negative, as base is shorter */
j++;
}
return 0;
More information about the Pinfo-devel
mailing list