Source: bogl
Severity: minor
Tags: patch
User: [email protected]
Usertags: clang-ftbfs
Hello,
Using the rebuild infrastructure, your package fails to build with clang
(instead of gcc).
We detected this kinf of error:
http://clang.debian.net/status.php?version=3.5.0rc1&key=NOT_ALLOWED_HERE
Full build log is available here:
http://clang.debian.net/logs/2014-08-05/bogl_0.1.18-9_unstable_clang.log
Thanks,
Alexander
-- System Information:
Debian Release: jessie/sid
APT prefers unstable
APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 3.2.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
--- ./bogl-vga16.c 2014-08-02 15:57:48.000000000 +0400
+++ ../bogl-0.1.18-my/./bogl-vga16.c 2014-08-02 15:37:50.740238641 +0400
@@ -324,22 +324,10 @@
bogl_drawing = 0;
}
-/* FIXME: it would be faster to use write mode 3 to write the middle
- bytes (but also more complex). */
#define ul_size (sizeof (u_int32_t))
#define ul_bits (CHAR_BIT * ul_size)
-void
-bogl_vga16_text (int xx, int yy, const char *s, int n, int fg, int bg, int ul,
- const struct bogl_font *font)
-{
- /* Font height, or possibly less due to clipping. */
- int h;
- int x, y;
- u_int32_t bits[font->height];
- int k;
- wchar_t wc;
- void plot (int bg)
+void plot (int bg, int xx, int yy, int h, u_int32_t *bits)
{
volatile char *dst = bogl_frame + xx / 8 + yy * bogl_line_len;
int y, i;
@@ -362,6 +350,19 @@
}
}
+/* FIXME: it would be faster to use write mode 3 to write the middle
+ bytes (but also more complex). */
+void
+bogl_vga16_text (int xx, int yy, const char *s, int n, int fg, int bg, int ul,
+ const struct bogl_font *font)
+{
+ /* Font height, or possibly less due to clipping. */
+ int h;
+ int x, y;
+ u_int32_t bits[font->height];
+ int k;
+ wchar_t wc;
+
assert (xx >= 0 && xx < bogl_xres);
assert (yy >= 0 && yy < bogl_yres);
@@ -404,7 +405,7 @@
if (x >= (int) ul_bits)
{
- plot (bg);
+ plot (bg, xx, yy, h, bits);
x -= ul_bits;
for (y = 0; y < h; y++)
@@ -415,7 +416,7 @@
goto done;
}
}
- plot (bg);
+ plot (bg, xx, yy, h, bits);
done:
bogl_drawing = 0;
--- ./bogl-font.c 2014-08-02 15:57:48.000000000 +0400
+++ ../bogl-0.1.18-my/./bogl-font.c 2014-08-02 15:56:57.367111738 +0400
@@ -38,60 +38,26 @@
};
/* Returns nonzero iff LINE begins with PREFIX. */
-static inline int
-matches_prefix (const char *line, const char *prefix)
+static inline int matches_prefix (const char *line, const char *prefix)
{
return !strncmp (line, prefix, strlen (prefix));
}
-/* Reads a .bdf font file in FILENAME into a struct bogl_font, which
- is returned. On failure, returns NULL, in which case an error
- message can be retrieved using bogl_error(). */
-struct bogl_font *
-bogl_read_bdf (char *filename)
-{
- char *font_name;
- int font_height;
- struct bogl_glyph *font_glyphs[1<<INDEX_BITS];
-
- /* Line buffer, current buffer size, and line number in input file. */
- char *line;
- size_t line_size;
- int ln = 0;
-
- /* Number of characters in font, theoretically, and the number that
- we've seen. These can be different at the end because there may
- be named characters in the font that aren't encoded into
- character set. */
- int n_chars;
- int char_index;
-
- /* Font ascent and descent in pixels. */
- int ascent;
- int descent;
-
- /* Character to substitute when a character lacks a glyph of its
- own. Normally the space character. */
- int default_char;
-
- /* .bdf file. */
- FILE *file;
-
/* Read a line from FILE. Returns nonzero if successful, reports an
error message using bogl_fail() if not. Strips trailing
whitespace from input line. */
- int read_line (void)
+static int read_line (int *ln, char **line, size_t *line_size, FILE *file, char *filename)
{
ssize_t len;
- ln++;
- len = getline (&line, &line_size, file);
+ (*ln)++;
+ len = getline (line, line_size, file);
if (len == -1)
{
if (ferror (file))
return bogl_fail ("reading %s: %s", filename, strerror (errno));
else
- return bogl_fail ("%s:%d: unexpected end of file", filename, ln);
+ return bogl_fail ("%s:%d: unexpected end of file", filename, *ln);
}
while (len > 0 && isspace ((unsigned char) line[len - 1]))
@@ -103,12 +69,11 @@
/* Attempt to malloc NBYTES bytes. Sets a BOGL error message on
failure. Returns the result of the malloc() operation in any
case. */
- void *
- smalloc (size_t nbytes)
+static void *smalloc(size_t nbytes)
{
void *p = malloc (nbytes);
if (p == NULL)
- bogl_fail ("%s:%d: virtual memory exhausted", filename, ln);
+ bogl_fail ("virtual memory exhausted");
return p;
}
@@ -117,44 +82,50 @@
On success will always: set ascent, descent, default_char,
font_height, and initialize font_glyphs. */
- int read_bdf_header (void)
+static int read_bdf_header (int *ln, char **line, size_t *line_size, FILE *file, char *filename, int *default_char, int *font_height, int *descent)
{
int bbx = 0, bby = 0, bbw = 0, bbh = 0;
- ascent = descent = 0;
- default_char = ' ';
+ /* Font ascent and descent in pixels. */
+ int ascent = 0;
+ *default_char = ' ';
for (;;)
{
- if (!read_line ())
+ if (!read_line (ln, line, line_size, file, filename))
return 0;
- if (matches_prefix (line, "FONT_ASCENT "))
- ascent = atoi (line + strlen ("FONT_ASCENT "));
- else if (matches_prefix (line, "FONT_DESCENT"))
- descent = atoi (line + strlen ("FONT_DESCENT"));
- else if (matches_prefix (line, "DEFAULT_CHAR "))
- default_char = atoi (line + strlen ("DEFAULT_CHAR "));
- else if (matches_prefix (line, "FONTBOUNDINGBOX "))
- sscanf (line + strlen ("FONTBOUNDINGBOX "), "%d %d %d %d",
+ if (matches_prefix (*line, "FONT_ASCENT "))
+ ascent = atoi (*line + strlen ("FONT_ASCENT "));
+ else if (matches_prefix (*line, "FONT_DESCENT"))
+ *descent = atoi (*line + strlen ("FONT_DESCENT"));
+ else if (matches_prefix (*line, "DEFAULT_CHAR "))
+ *default_char = atoi (*line + strlen ("DEFAULT_CHAR "));
+ else if (matches_prefix (*line, "FONTBOUNDINGBOX "))
+ sscanf (*line + strlen ("FONTBOUNDINGBOX "), "%d %d %d %d",
&bbw, &bbh, &bbx, &bby);
- else if (matches_prefix (line, "CHARS "))
+ else if (matches_prefix (*line, "CHARS "))
break;
}
- n_chars = atoi (line + strlen ("CHARS "));
+ /* Number of characters in font, theoretically, and the number that
+ we've seen. These can be different at the end because there may
+ be named characters in the font that aren't encoded into
+ character set. */
+ int n_chars = 0;
+ n_chars = atoi (*line + strlen ("CHARS "));
if (n_chars < 1)
return bogl_fail ("%s:%d: font contains no characters", filename, ln);
/* Adjust ascent and descent based on bounding box. */
- if (-bby > descent)
- descent = -bby;
+ if (-bby > *descent)
+ *descent = -bby;
if (bby + bbh > ascent)
ascent = bby + bbh;
- font_height = ascent + descent;
- if (font_height <= 0)
+ *font_height = ascent + *descent;
+ if (*font_height <= 0)
return bogl_fail ("%s:%d: font ascent (%d) + descent (%d) must be "
- "positive", filename, ln, ascent, descent);
+ "positive", filename, *ln, ascent, *descent);
return 1;
}
@@ -164,7 +135,8 @@
Sets the character data into font->content, font->offset, and
font->width as appropriate. Updates char_index. */
- int read_character (void)
+int read_character (int *ln, char **line, size_t *line_size, FILE *file, char *filename, struct bogl_glyph **font_glyphs, int *font_height, int *descent,
+ int *char_index)
{
int encoding = -1;
int width = INT_MIN;
@@ -173,17 +145,17 @@
/* Read everything for this character up to the bitmap. */
for (;;)
{
- if (!read_line ())
+ if (!read_line (ln, line, line_size, file, filename))
return 0;
- if (matches_prefix (line, "ENCODING "))
- encoding = atoi (line + strlen ("ENCODING "));
- else if (matches_prefix (line, "DWIDTH "))
- width = atoi (line + strlen ("DWIDTH "));
- else if (matches_prefix (line, "BBX "))
- sscanf (line + strlen ("BBX "), "%d %d %d %d",
+ if (matches_prefix (*line, "ENCODING "))
+ encoding = atoi (*line + strlen ("ENCODING "));
+ else if (matches_prefix (*line, "DWIDTH "))
+ width = atoi (*line + strlen ("DWIDTH "));
+ else if (matches_prefix (*line, "BBX "))
+ sscanf (*line + strlen ("BBX "), "%d %d %d %d",
&bbw, &bbh, &bbx, &bby);
- else if (matches_prefix (line, "BITMAP"))
+ else if (matches_prefix (*line, "BITMAP"))
break;
}
@@ -215,8 +187,7 @@
*t = smalloc (sizeof (struct bogl_glyph));
if (*t == NULL)
return 0;
- content = smalloc (sizeof (u_int32_t) *
- font_height * ((width + 31)/32));
+ content = smalloc (sizeof (u_int32_t) * *font_height * ((width + 31)/32));
if (content == NULL)
{
free (*t);
@@ -225,7 +196,7 @@
}
memset(content, 0,
- sizeof (u_int32_t) * font_height * ((width + 31)/32));
+ sizeof (u_int32_t) * *font_height * ((width + 31)/32));
(*t)->char_width = (encoding & ~INDEX_MASK) | width;
(*t)->next = NULL;
(*t)->content = content;
@@ -236,29 +207,29 @@
for (i = 0; ; i++) {
int row;
- if (!read_line ())
+ if (!read_line (ln, line, line_size, file, filename))
return 0;
- if (matches_prefix (line, "ENDCHAR"))
+ if (matches_prefix (*line, "ENDCHAR"))
break;
if (encoding == -1)
continue;
- row = font_height - descent - bby - bbh + i;
- if (row < 0 || row >= font_height)
+ row = *font_height - *descent - bby - bbh + i;
+ if (row < 0 || row >= *font_height)
continue;
- bm[row] = strtol (line, NULL, 16) << (32 - 4 * strlen (line) - bbx);
+ bm[row] = strtol (*line, NULL, 16) << (32 - 4 * strlen (*line) - bbx);
}
}
/* Advance to next glyph. */
if (encoding != -1)
- char_index++;
+ (*char_index)++;
return 1;
}
- void free_font_glyphs (void)
+static void free_font_glyphs (struct bogl_glyph **font_glyphs)
{
int i;
struct bogl_glyph *t, *tnext;
@@ -271,10 +242,33 @@
}
}
+/* Reads a .bdf font file in FILENAME into a struct bogl_font, which
+ is returned. On failure, returns NULL, in which case an error
+ message can be retrieved using bogl_error(). */
+struct bogl_font *bogl_read_bdf (char *filename)
{
+ char *font_name;
+ int font_height;
+ struct bogl_glyph *font_glyphs[1<<INDEX_BITS];
+
+ /* Line buffer, current buffer size, and line number in input file. */
+ char *line = NULL;
+ size_t line_size;
+ int ln = 0;
+
+ int char_index;
+
+ /* Character to substitute when a character lacks a glyph of its
+ own. Normally the space character. */
+ int default_char;
+
+ /* .bdf file. */
+ FILE *file;
+
int i;
for (i = 0; i < (1<<INDEX_BITS); i++)
+ {
font_glyphs[i] = NULL;
}
@@ -300,45 +294,50 @@
cp = (unsigned char *) strstr (font_name, ".bdf");
if (cp)
+ {
*cp = 0;
+ }
for (cp = (unsigned char *) font_name; *cp; cp++)
+ {
if (!isalnum (*cp))
+ {
*cp = '_';
}
+ }
+ }
- line = NULL;
line_size = 0;
char_index = 0;
+ int descent= 0;
/* Read the header. */
- if (!read_bdf_header ())
+ if (!read_bdf_header(&ln, &line, &line_size, file, filename, &default_char, &font_height, &descent))
+ {
goto lossage;
+ }
/* Read all the glyphs. */
{
for (;;)
{
- if (!read_line ())
+ if (!read_line(&ln, &line, &line_size, file, filename))
+ {
goto lossage;
+ }
if (matches_prefix (line, "STARTCHAR "))
{
-#if 0
- if (char_index >= n_chars)
+ if (!read_character(&ln, &line, &line_size, file, filename, font_glyphs, &font_height, &descent, &char_index))
{
- bogl_fail ("%s:%d: font contains more characters than "
- "declared", filename, ln);
goto lossage;
}
-#endif
-
- if (!read_character ())
- goto lossage;
}
else if (matches_prefix (line, "ENDFONT"))
+ {
break;
}
+ }
/* Make sure that we found at least one encoded character. */
if (!char_index)
@@ -420,7 +419,7 @@
font->default_char = default_char;
/* Clean up. */
- free_font_glyphs ();
+ free_font_glyphs (font_glyphs);
fclose (file);
free (line);
return font;
@@ -428,15 +427,14 @@
lossage:
/* Come here on error. */
- free_font_glyphs ();
+ free_font_glyphs (font_glyphs);
free (line);
fclose (file);
return NULL;
}
/* Free FONT. */
-void
-bogl_free_font (struct bogl_font *font)
+void bogl_free_font (struct bogl_font *font)
{
free (font->name);
free (font->offset);