* prof_parse.c (strip_line): Simplify loop by preserving "p" rather than
authorKen Raeburn <raeburn@mit.edu>
Wed, 19 Jun 2002 21:03:00 +0000 (21:03 +0000)
committerKen Raeburn <raeburn@mit.edu>
Wed, 19 Jun 2002 21:03:00 +0000 (21:03 +0000)
recomputing it.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@14542 dc483132-0cff-0310-8789-dd5450dbe970

src/util/profile/ChangeLog
src/util/profile/prof_parse.c

index d9f30d867fd47ca895fe71fcb8af9e064797f499..83bbca78b058ad5e9fc1aa9a75a2c4a6d1241f71 100644 (file)
@@ -1,5 +1,8 @@
 2002-06-19  Ken Raeburn  <raeburn@mit.edu>
 
+       * prof_parse.c (strip_line): Simplify loop by preserving "p"
+       rather than recomputing it.
+
        * configure.in: Look for strdup.
        * prof_tree.c (profile_create_node): Use strdup.
        (strdup, MYstrdup): Define it if the OS doesn't provide it.
index 844d66a57840d6fe1e810a521925eb1bf040945b..019fabe25722f25529a3537c49fe429359d6081b 100644 (file)
@@ -32,15 +32,9 @@ static char *skip_over_blanks(cp)
 static void strip_line(line)
        char    *line;
 {
-       char    *p;
-
-       while (*line) {
-               p = line + strlen(line) - 1;
-               if ((*p == '\n') || (*p == '\r'))
-                       *p = 0;
-               else
-                       break;
-       }
+       char *p = line + strlen(line);
+       while (p > line && (p[-1] == '\n' || p[-1] == '\r'))
+           *p-- = 0;
 }
 
 static void parse_quoted_string(char *str)