aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2022-10-05 00:30:49 +0200
committerThomas Voss <mail@thomasvoss.com> 2022-10-05 00:30:49 +0200
commitb8f69cd86d56acf9320d2424f290e30f317be5f2 (patch)
tree4d138640fa74b2f509b1f5ff80213114b7627626
parenta22d3b91339a5e063461be948596e9da88ce0d35 (diff)
Wrap code to 80 columns
With my new laptop setup and stuff, 80 characters is about half of the screen; wrapping code to 80 columns allows me to have two terminals in a split screen while viewing all the code.
-rw-r--r--center.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/center.c b/center.c
index 60e5355..309e17a 100644
--- a/center.c
+++ b/center.c
@@ -89,7 +89,11 @@ main(int argc, char **argv)
warnx("Potential overflow of given width");
break;
default:
- fprintf(stderr, "Usage: %s [-el] [-t tab width] [-w width] [file ...]\n", argv[0]);
+ fprintf(
+ stderr,
+ "Usage: %s [-el] [-t tab width] [-w width] [file ...]\n",
+ argv[0]
+ );
exit(EXIT_FAILURE);
}
}
@@ -120,7 +124,9 @@ main(int argc, char **argv)
return rval;
}
-/* Write the contents of the file pointed to by `fp' center aligned to the standard output */
+/* Write the contents of the file pointed to by `fp' center aligned to the
+ * standard output.
+ */
void
center(FILE *fp)
{
@@ -147,8 +153,8 @@ center(FILE *fp)
}
}
-/* Same as center(), but aligns all lines according to the longest line.
- * Great for centering code.
+/* Same as center(), but aligns all lines according to the longest line. Great
+ * for centering code.
*/
void
center_by_longest(FILE *fp)
@@ -178,7 +184,7 @@ center_by_longest(FILE *fp)
if (curr_len > longest)
longest = curr_len;
- /* Reset buffer and bs so getline can allocate a new buffer next time */
+ /* Reset buffer and bs so getline() can alloc a new buffer */
buffer = NULL;
bs = 0;
}
@@ -204,7 +210,9 @@ center_by_longest(FILE *fp)
}
}
-/* Return the column width of the output device if it is a TTY. If it is not a TTY then return -1 */
+/* Return the column width of the output device if it is a TTY. If it is not a
+ * TTY then return -1.
+ */
int
cols(void)
{
@@ -233,8 +241,9 @@ utf8len(const char *s)
return l;
}
-/* Return the length of the UTF-8 encoded string `s' in characters, not bytes. Additionally this
- * function ignores ANSI color escape sequences when computing the length.
+/* Return the length of the UTF-8 encoded string `s' in characters, not bytes.
+ * Additionally this function ignores ANSI color escape sequences when computing
+ * the length.
*/
int
noesclen(const char *s)
@@ -248,9 +257,10 @@ noesclen(const char *s)
return utf8len(s) - off;
}
-/* Return the length of the ANSI color escape sequence at the beginning of the string `s'. If no
- * escape sequence is matched then 0 is returned. The local variable `c' is initialized to 3 in order
- * to account for the leading ESC, the following `[', and the trailing `m'.
+/* Return the length of the ANSI color escape sequence at the beginning of the
+ * string `s'. If no escape sequence is matched then 0 is returned. The local
+ * variable `c' is initialized to 3 in order to account for the leading ESC, the
+ * following `[', and the trailing `m'.
*/
int
matchesc(const char *s)