Removed trailing whitespace from src and tests

This commit is contained in:
James Booth
2012-10-21 20:02:20 +01:00
parent 382e961563
commit 6bad38c2d5
35 changed files with 446 additions and 446 deletions

View File

@@ -1,8 +1,8 @@
/*
/*
* common.c
*
* Copyright (C) 2012 James Booth <boothj5@gmail.com>
*
*
* This file is part of Profanity.
*
* Profanity is free software: you can redistribute it and/or modify
@@ -50,20 +50,20 @@ create_dir(char *name)
}
char *
str_replace(const char *string, const char *substr,
const char *replacement)
str_replace(const char *string, const char *substr,
const char *replacement)
{
char *tok = NULL;
char *newstr = NULL;
char *oldstr = NULL;
char *head = NULL;
if (string == NULL)
return NULL;
if ( substr == NULL ||
replacement == NULL ||
(strcmp(substr, "") == 0))
if ( substr == NULL ||
replacement == NULL ||
(strcmp(substr, "") == 0))
return strdup (string);
newstr = strdup (string);
@@ -71,26 +71,26 @@ str_replace(const char *string, const char *substr,
while ( (tok = strstr ( head, substr ))) {
oldstr = newstr;
newstr = malloc ( strlen ( oldstr ) - strlen ( substr ) +
newstr = malloc ( strlen ( oldstr ) - strlen ( substr ) +
strlen ( replacement ) + 1 );
if ( newstr == NULL ) {
if ( newstr == NULL ) {
free (oldstr);
return NULL;
}
memcpy ( newstr, oldstr, tok - oldstr );
memcpy ( newstr + (tok - oldstr), replacement, strlen ( replacement ) );
memcpy ( newstr + (tok - oldstr) + strlen( replacement ),
tok + strlen ( substr ),
memcpy ( newstr + (tok - oldstr) + strlen( replacement ),
tok + strlen ( substr ),
strlen ( oldstr ) - strlen ( substr ) - ( tok - oldstr ) );
memset ( newstr + strlen ( oldstr ) - strlen ( substr ) +
memset ( newstr + strlen ( oldstr ) - strlen ( substr ) +
strlen ( replacement ) , 0, 1 );
head = newstr + (tok - oldstr) + strlen( replacement );
free (oldstr);
}
return newstr;
}