]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Simplify for_each_line()
authorAndre <maan@p133.(none)>
Sun, 5 Mar 2006 13:18:24 +0000 (14:18 +0100)
committerAndre <maan@p133.(none)>
Sun, 5 Mar 2006 13:18:24 +0000 (14:18 +0100)
It is always called with the num parameter being zero. So nuke that
parameter and update the docs.

audiod.c
gui.c
gui_common.c
para.h
plm_dbtool.c
stat.c

index 552577d538d4815f90e79b76c572a7fc28439fb9..ede35ab02e6ac97738fcaae3659929a49dc82287 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -1545,7 +1545,7 @@ repeat:
                } else {
                        status_buf[ret + sbo] = '\0';
                        sbo = for_each_line(status_buf, ret + sbo,
-                               &check_stat_line, 0);
+                               &check_stat_line);
                }
        }
        slot_io(&wfds);
diff --git a/gui.c b/gui.c
index a347e79c155d47186f7fe006759dfb05ba34e0cc..9b1c739f2110d6e05c0d27e0a832472d72b5b149 100644 (file)
--- a/gui.c
+++ b/gui.c
@@ -937,7 +937,7 @@ check_return:
                if (cp_numread <= 0 && !cbo) /* command complete */
                        return 0;
                if (cbo)
-                       cbo = for_each_line(command_buf, cbo, &add_output_line, 0);
+                       cbo = for_each_line(command_buf, cbo, &add_output_line);
                if (cp_numread <= 0)
                        cbo = 0;
                wrefresh(bot.win);
index d806ebe2df2b6e741ce80837fc59e3c28acb9536..07cab16fe211c740c7a25a484e1fee5271490498 100644 (file)
@@ -24,7 +24,7 @@ int read_audiod_pipe(int fd, void (*line_handler)(char *) )
        if (ret > 0) {
                loaded += ret;
                buf[loaded] = '\0';
-               loaded = for_each_line(buf, loaded, line_handler, 0);
+               loaded = for_each_line(buf, loaded, line_handler);
        }
        return ret;
 }
diff --git a/para.h b/para.h
index 049262d39d75074a84e7bdf984e4e1c1c48258bd..f3e67ed9c1213b13c3a486767564799421e089e4 100644 (file)
--- a/para.h
+++ b/para.h
@@ -163,7 +163,7 @@ int stat_line_valid(const char *);
 void stat_client_write(char *msg);
 int stat_client_add(int);
 void dump_empty_status(void);
-unsigned for_each_line(char *, int, void (*)(char *), int);
+unsigned for_each_line(char *, int, void (*)(char *));
 
 struct stat_item_data {
        char *prefix, *postfix;
index 3b551fcd5e36ab68e227a0364e1fa6e9b3fc877c..ad6a95b14ec316057a7114c7fd29e7366341d962 100644 (file)
@@ -248,7 +248,7 @@ static void plm_post_select(__unused fd_set *rfds, __unused fd_set *wfds)
                goto out;
        }
        PARA_DEBUG_LOG("loading new playlist (%d bytes)\n", pcd->size);
-       ret = for_each_line((char *)shm, pcd->size, &playlist_add, 0);
+       ret = for_each_line((char *)shm, pcd->size, &playlist_add);
        shm_detach(shm);
        PARA_NOTICE_LOG("new playlist (%d entries)\n", playlist_len);
        pcd->retval = 1;
diff --git a/stat.c b/stat.c
index 7550f2d6d2f33d684be389417589efe4a75dd71c..4ad1b5a88d957f411c5ccad6bb00f871e440f842 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -234,18 +234,16 @@ int stat_line_valid(const char *line)
  * \param buf the buffer containing data seperated by newlines
  * \param n the number of bytes in \a buf
  * \param line_handler the custom function
- * \param num upper bound on calls to \a line_handler
  *
  * If \a line_handler is \p NULL, return number of complete lines in buf.
- * Otherwise, call \a line_handler for each complete line, but no more than \a num
- * times. If \a num is zero, there is no restriction on how often \a line_handler
- * may be called. The rest of the buffer (last chunk containing incomplete line
- * if \a num is zero) is moved to the beginning of the buffer.
+ * Otherwise, call \a line_handler for each complete line.  The rest of the
+ * buffer (last chunk containing incomplete line is moved to the beginning of
+ * the buffer.
  *
  * \return If line_handler is not NULL, this function returns the number
  * of bytes not handled to \a line_handler.
  */
-unsigned for_each_line(char *buf, int n, void (*line_handler)(char *), int num)
+unsigned for_each_line(char *buf, int n, void (*line_handler)(char *))
 {
        char *start = buf, *end;
        int i, num_lines = 0;
@@ -269,8 +267,6 @@ unsigned for_each_line(char *buf, int n, void (*line_handler)(char *), int num)
                        *end = '\0';
                        line_handler(start);
                        start = ++end;
-                       if (num && num_lines >= num)
-                               break;
                } else
                        start = ++end;
        }