From 2e5f1c8955cb705db46e397703d16e46da2b11f8 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 5 May 2009 09:05:09 +0000 Subject: [PATCH] Improve get_equals(). git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@739 7dcaeef0-15fb-0310-b436-a5af3365683c --- libssh/base64.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/libssh/base64.c b/libssh/base64.c index 15636d73..42ee52bf 100644 --- a/libssh/base64.c +++ b/libssh/base64.c @@ -213,17 +213,18 @@ static int _base64_to_bin(unsigned char dest[3], const char *source, int num) { return 0; } -/* counts the number of "=" signs, and replace them by zeroes */ -static int get_equals(char *string){ - char *ptr=string; - int num=0; - while((ptr=strchr(ptr,'='))){ - num++; - *ptr=0; - ptr++; - } +/* Count the number of "=" signs and replace them by zeroes */ +static int get_equals(char *string) { + char *ptr = string; + int num = 0; - return num; + while ((ptr=strchr(ptr,'=')) != NULL) { + num++; + *ptr = '\0'; + ptr++; + } + + return num; } /* thanks sysk for debugging my mess :) */