[hackers] [sbase] tsort style fixes || sin

From: <git_AT_suckless.org>
Date: Wed, 24 Feb 2016 16:57:41 +0100 (CET)

commit 9a2b8d3531ec0cf3f3e91a61d1a89b3b912d5287
Author: sin <sin_AT_2f30.org>
AuthorDate: Wed Feb 24 15:56:39 2016 +0000
Commit: sin <sin_AT_2f30.org>
CommitDate: Wed Feb 24 15:57:33 2016 +0000

    tsort style fixes
    
    getline() cannot return 0 so no need to guard against that.

diff --git a/tsort.c b/tsort.c
index cb4997a..d093df8 100644
--- a/tsort.c
+++ b/tsort.c
_AT_@ -6,9 +6,7 @@
 
 #include "util.h"
 
-#define WHITE 0
-#define GREY 1
-#define BLACK 2
+enum { WHITE = 0, GREY, BLACK };
 
 struct vertex;
 
_AT_@ -41,7 +39,7 @@ find_vertex(const char *name, struct vertex **it, struct vertex **prev)
 }
 
 static void
-find_edge(struct vertex* from, const char *to, struct edge **it, struct edge **prev)
+find_edge(struct vertex *from, const char *to, struct edge **it, struct edge **prev)
 {
         for (*prev = &(from->edges); (*it = (*prev)->next); *prev = *it) {
                 int cmp = strcmp(to, (*it)->to->name);
_AT_@ -72,7 +70,7 @@ add_vertex(char *name)
 }
 
 static struct edge *
-add_edge(struct vertex* from, struct vertex* to)
+add_edge(struct vertex *from, struct vertex* to)
 {
         struct edge *edge;
         struct edge *prev;
_AT_@ -104,8 +102,8 @@ load_graph(FILE *fp)
         struct vertex *from = 0;
 
         while ((len = getline(&line, &size, fp)) != -1) {
- if (len && line[len - 1] == '\n')
- line[len - 1] = 0;
+ if (line[len - 1] == '\n')
+ line[--len] = 0;
                 for (p = line; p;) {
                         SKIP(name, p, isspace);
                         if (!*name)
Received on Wed Feb 24 2016 - 16:57:41 CET

This archive was generated by hypermail 2.3.0 : Wed Feb 24 2016 - 17:00:14 CET