bcc: generates only unsigned arrays

Fri, 20 Nov 2020 11:25:05 +0100

author
David Demelier <markand@malikania.fr>
date
Fri, 20 Nov 2020 11:25:05 +0100
changeset 3
b91e030a2040
parent 2
3ac0425e90ce
child 4
327e7d392f19

bcc: generates only unsigned arrays

README.md file | annotate | diff | comparison | revisions
bcc.1 file | annotate | diff | comparison | revisions
bcc.c file | annotate | diff | comparison | revisions
--- a/README.md	Wed Oct 21 15:30:12 2020 +0200
+++ b/README.md	Fri Nov 20 11:25:05 2020 +0100
@@ -9,7 +9,7 @@
 
 Example: convert a image for embedding.
 
-	bcc -scu mario.png mario > mario.h
+	bcc -sc mario.png mario > mario.h
 
 Now, you can include mario.h file and use `mario` C array, `sizeof (mario)` is
 also possible.
--- a/bcc.1	Wed Oct 21 15:30:12 2020 +0200
+++ b/bcc.1	Fri Nov 20 11:25:05 2020 +0100
@@ -23,9 +23,9 @@
 .\" SYNOPSIS
 .Sh SYNOPSIS
 .Nm bcc
-.Op Fl 0csu
-.Op Fl I Ar tab-indent
-.Op Fl i Ar space-indent
+.Op Fl 0cs
+.Op Fl I Ar num
+.Op Fl i Ar num
 .Ar filename
 .Ar variable
 .\" DESCRIPTION
@@ -60,24 +60,21 @@
 .Em const
 array.
 .It Fl s
-Generate a
+Generates a
 .Em static
 array.
-.It Fl u
-Use an
-.Em unsigned
-char rather than
-.Em signed .
-.It Fl I Ar tab-indent
-.Ar tab-indent
-count as leading indents.
-.It Fl i Ar space-indent
-.Ar space-indent
-count as leading indents.
+.It Fl I Ar num
+Use
+.Ar num
+count as leading tab indents.
+.It Fl i Ar num
+Use
+.Ar num
+count as leading space indents.
 .El
 .\" EXAMPLES
 .Sh EXAMPLES
-Create a static, const, unsigned array from an image.
+Create a static, const array from an image.
 .Bd -literal -offset indent
 bcc -scu image.png image > image.h
 .Ed
--- a/bcc.c	Wed Oct 21 15:30:12 2020 +0200
+++ b/bcc.c	Fri Nov 20 11:25:05 2020 +0100
@@ -31,12 +31,11 @@
 static bool fconst;
 static bool fnull;
 static bool fstatic;
-static bool funsigned;
 
 noreturn static void
 usage(void)
 {
-	fprintf(stderr, "usage: bcc [-0csu] [-I tab-indent] [-i space-indent] input variable\n");
+	fprintf(stderr, "usage: bcc [-0csu] [-I num] [-i num] [-t signedness] input variable\n");
 	exit(1);
 }
 
@@ -79,10 +78,7 @@
 static void
 put(int ch)
 {
-	if (funsigned)
-		printf("0x%02hhx", (unsigned char)ch);
-	else
-		printf("%hhd", (signed char)ch);
+	printf("0x%02hhx", (unsigned char)ch);
 }
 
 static void
@@ -101,8 +97,7 @@
 	if (fconst)
 		printf("const ");
 
-	printf(funsigned ? "unsigned " : "signed ");
-	printf("char %s[] = {\n", variable);
+	printf("unsigned char %s[] = {\n", variable);
 
 	for (ch = fgetc(fp); ch != EOF; ) {
 		if (col == 0)
@@ -139,7 +134,7 @@
 {
 	int ch;
 
-	while ((ch = getopt(argc, argv, "0cI:i:su")) != -1) {
+	while ((ch = getopt(argc, argv, "0cI:i:s")) != -1) {
 		switch (ch) {
 		case '0':
 			fnull = true;
@@ -158,9 +153,6 @@
 		case 's':
 			fstatic = true;
 			break;
-		case 'u':
-			funsigned = true;
-			break;
 		default:
 			break;
 		}

mercurial