[Dctrl-tools-devel] [SCM] Debian control file query tools branch, master, updated. 2.11-40-gdb1cf52

Antti-Juhani Kaijanaho ajk at debian.org
Tue Jan 6 17:54:17 UTC 2009


The following commit has been merged in the master branch:
commit 5ae4b4a31d03ce7d9bbc72f13c48a480788c0ef4
Author: Antti-Juhani Kaijanaho <ajk at debian.org>
Date:   Tue Jan 6 19:45:56 2009 +0200

    tbl-dctrl.c [linewrap]: Clarify.
    
    Signed-off-by: Antti-Juhani Kaijanaho <ajk at debian.org>

diff --git a/debian/changelog b/debian/changelog
index 9da4cc9..b3bfb6f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -5,8 +5,9 @@ dctrl-tools (2.14) UNRELEASED; urgency=low
   * lib/msg.c: Remove (obsolete) snail mail and email addresses for me.
   * */*.[ch]: Use the copyright symbol instead of (c) or (C).
   * msg.[ch] (and others): allow the message functions to handle format strings
+  * tbl-dctrl.c [linewrap]: Clarify.
 
- -- Antti-Juhani Kaijanaho <ajk at debian.org>  Fri, 04 Jul 2008 19:35:16 +0300
+ -- Antti-Juhani Kaijanaho <ajk at debian.org>  Tue, 06 Jan 2009 19:45:11 +0200
 
 dctrl-tools (2.13.0) unstable; urgency=low
 
diff --git a/tbl-dctrl/tbl-dctrl.c b/tbl-dctrl/tbl-dctrl.c
index d6f3fd6..02f6caa 100644
--- a/tbl-dctrl/tbl-dctrl.c
+++ b/tbl-dctrl/tbl-dctrl.c
@@ -68,6 +68,16 @@ struct arguments {
 	struct ifile fname[MAX_FNAMES];
 };
 
+size_t linewrap(char **res, char const *orig, size_t orig_len,
+		size_t col_width)
+{
+	assert(col_width > 0);
+
+        // these are primarily manipulated by the INSERT macro below
+	size_t max = 16;        // the capacity of rv
+	char *rv = malloc(max); // the prospective return value
+	size_t len = 0;         // length of the string in rv
+
 #define INSERT(c) do { \
 	if (len >= max) { \
 		max *= 2; \
@@ -77,17 +87,12 @@ struct arguments {
 	rv[len++] = (c); \
 } while (0)
 
-size_t linewrap(char **res, char const *orig, size_t orig_len,
-		size_t col_width)
-{
-	assert(col_width > 0);
+	size_t ll = 0;          // the length of the current line, so far
 
-	size_t max = 16;
-	char *rv = malloc(max);
-	size_t len = 0;
-
-	size_t ll = 0;
-	size_t bpo = 0, bpr = 0;
+        // the following two record the location of the closest
+        // breakpoint so far
+	size_t bpo = 0;        // indexes orig
+        size_t bpr = 0;        // indexes rv
 
 	size_t num_lines = 1;
 
@@ -101,7 +106,7 @@ size_t linewrap(char **res, char const *orig, size_t orig_len,
 				assert(bpr < len);
 				len = bpr;
 				assert(bpo < i);
-				i = bpo;
+				i = bpo; 
 			}
 			ll = 0;
 			INSERT('\n');
@@ -122,9 +127,9 @@ size_t linewrap(char **res, char const *orig, size_t orig_len,
 	INSERT('\0');
 	*res = rv;
 	return num_lines;
+#undef INSERT
 }
 
-
 void print_line(struct arguments *args,
 		struct fsaf_read_rv const columns[/*args->num_columns*/])
 {

-- 
Debian control file query tools



More information about the Dctrl-tools-devel mailing list