summaryrefslogtreecommitdiffstats
path: root/source/history.c
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2016-04-10 14:30:13 +0200
committerDave Davenport <qball@gmpclient.org>2016-04-10 14:30:13 +0200
commit96cb3a8695e35890d2f10aa508c33f2ebac40d35 (patch)
tree14b4efeda679962673878dd4310b49e74754a425 /source/history.c
parentb63f8e22754148e859b2ebf463353abfb9a17dbe (diff)
Remove fgets and replace by getline.
Diffstat (limited to 'source/history.c')
-rw-r--r--source/history.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/source/history.c b/source/history.c
index 612f0e66..094b9bcc 100644
--- a/source/history.c
+++ b/source/history.c
@@ -84,10 +84,10 @@ static _element ** __history_get_element_list ( FILE *fd, unsigned int *length )
if ( fd == NULL ) {
return NULL;
}
- char *buffer = NULL;
- size_t buffer_length = 0;
- ssize_t l = 0;
- while ( (l = getline ( &buffer, &buffer_length, fd )) > 0 ) {
+ char *buffer = NULL;
+ size_t buffer_length = 0;
+ ssize_t l = 0;
+ while ( ( l = getline ( &buffer, &buffer_length, fd ) ) > 0 ) {
char * start = NULL;
// Skip empty lines.
if ( strlen ( buffer ) == 0 ) {
@@ -101,9 +101,9 @@ static _element ** __history_get_element_list ( FILE *fd, unsigned int *length )
buffer[strlen ( buffer ) - 1] = '\0';
// Parse the number of times.
retv[( *length )]->index = strtol ( buffer, &start, 10 );
- retv[( *length )]->name = g_strndup(start+1, l-1-(start+1-buffer));
+ retv[( *length )]->name = g_strndup ( start + 1, l - 1 - ( start + 1 - buffer ) );
// Force trailing '\0'
- retv[( *length ) + 1] = NULL;
+ retv[( *length ) + 1] = NULL;
( *length )++;
}
@@ -152,7 +152,7 @@ void history_set ( const char *filename, const char *entry )
list[length] = g_malloc ( sizeof ( _element ) );
// Copy name
if ( list[length] != NULL ) {
- list[length]->name = g_strdup(entry);
+ list[length]->name = g_strdup ( entry );
// set # hits
list[length]->index = 1;