From 3584efdf4b299ef9ac78d210a90fefb41139e161 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sun, 24 Jan 2010 21:58:17 +0000 Subject: [PATCH] Fix the source code to reduce testsuite errors. --- caca/codec/export.c | 33 ++++++++++++++++----------------- kernel/Makefile.am | 2 ++ kernel/kernel.c | 12 ++++++------ kernel/kernel.h | 12 +++++------- kernel/klibc.h | 0 kernel/multiboot.h | 18 +++++++++--------- test/check-build | 5 +++-- win32/config.h | 1 + 8 files changed, 42 insertions(+), 41 deletions(-) mode change 100755 => 100644 kernel/klibc.h diff --git a/caca/codec/export.c b/caca/codec/export.c index 86afac7..5c6b761 100644 --- a/caca/codec/export.c +++ b/caca/codec/export.c @@ -992,13 +992,12 @@ static void *export_tga(caca_canvas_t const *cv, size_t *bytes) */ static uint8_t _rgb_to_troff_index(uint32_t color) { - int i; - uint8_t r = 0; - for(i = 0; i < 3; i++) - { - r += ((color >> (8*i+7))&1) << i; - } - return r; + int i; + uint8_t r = 0; + for(i = 0; i < 3; i++) + r += ((color >> (8 * i + 7)) & 1) << i; + + return r; } /* Generate troff representation of current canvas. */ @@ -1014,7 +1013,7 @@ static void *export_troff(caca_canvas_t const *cv, size_t *bytes) uint32_t prevbg = 0; int started = 0; - /* Each char is at most + /* Each char is at most * 2x\mM (2x10) * + \fB + \fI + \fR (9) * + 4 bytes = 33 @@ -1037,14 +1036,14 @@ static void *export_troff(caca_canvas_t const *cv, size_t *bytes) for(x = 0; x < cv->width; x++) { - uint32_t fg = _rgb_to_troff_index(_caca_attr_to_rgb24fg(lineattr[x])); - uint32_t bg = _rgb_to_troff_index(_caca_attr_to_rgb24bg(lineattr[x])); - uint32_t ch = linechar[x]; - - if(fg != prevfg || !started) - cur += sprintf(cur, "\\m[%s]", colors[fg]); - if(bg != prevbg || !started) - cur += sprintf(cur, "\\M[%s]", colors[bg]); + uint32_t fg = _rgb_to_troff_index(_caca_attr_to_rgb24fg(lineattr[x])); + uint32_t bg = _rgb_to_troff_index(_caca_attr_to_rgb24bg(lineattr[x])); + uint32_t ch = linechar[x]; + + if(fg != prevfg || !started) + cur += sprintf(cur, "\\m[%s]", colors[fg]); + if(bg != prevbg || !started) + cur += sprintf(cur, "\\M[%s]", colors[bg]); if(lineattr[x] & CACA_BOLD) cur += sprintf(cur, "\\fB"); if(lineattr[x] & CACA_ITALICS) @@ -1061,7 +1060,7 @@ static void *export_troff(caca_canvas_t const *cv, size_t *bytes) prevfg = fg; prevbg = bg; started = 1; - } + } /* Add unbreakable space at the end of lines, else spaces are dropped */ if(x > 0 && linechar[x-1] == ' ') diff --git a/kernel/Makefile.am b/kernel/Makefile.am index 99f1ffd..7d1bd2f 100644 --- a/kernel/Makefile.am +++ b/kernel/Makefile.am @@ -20,3 +20,5 @@ clean: clean-local clean-local: rm -f bootsect.bin kern.bin kernel.map +echo-sources: ; echo $(SOURCES) + diff --git a/kernel/kernel.c b/kernel/kernel.c index 2bdac1f..d921786 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -1,5 +1,5 @@ /* - * libcaca + * libcaca * libcaca Colour ASCII-Art library * Copyright (c) 2006 Sam Hocevar * 2009 Jean-Yves Lamoureux @@ -34,17 +34,17 @@ int kmain(void) { struct processor_info processor_info; struct floppy_info floppy_info; - + printf("_start at 0x%x\n", _start); printf("kmain() at 0x%x\n", kmain); printf("Types : char[%d] short[%d] int[%d] unsigned long long[%d]\n", sizeof(char), sizeof(short), sizeof(int), sizeof(unsigned long long)); - + enable_interrupt(1); // Enable Keyboard Interrupt (IRQ1) enable_interrupt(0); // Enable IRQ0 (timer) enable_interrupt(13); timer_phase(100); // Fire IRQ0 each 1/100s - - + + processor_get_info(&processor_info); processor_print_info(&processor_info); @@ -53,7 +53,7 @@ int kmain(void) /* Caca is delicious */ printf("Filling memory with 0xCACA, starting from 0x%x\n", end); - + char *ptr = end; while (1) { diff --git a/kernel/kernel.h b/kernel/kernel.h index c9c6dc5..fbb3f06 100644 --- a/kernel/kernel.h +++ b/kernel/kernel.h @@ -1,5 +1,5 @@ /* - * libcaca + * libcaca * libcaca Colour ASCII-Art library * Copyright (c) 2006 Sam Hocevar * 2009 Jean-Yves Lamoureux @@ -26,13 +26,11 @@ void dump_gdt(void); void disable_interrupt(char i); void enable_interrupt(char i); +#define cli __asm__("cli" : : ) +#define sti __asm__("sti" : : ) -#define cli __asm__("cli"::) -#define sti __asm__("sti"::) - -#define rdtsc(low,high) \ -__asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high)) - +#define rdtsc(low, high) \ + __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high)) /* The application's entry point */ int main(int argc, char *argv[]); diff --git a/kernel/klibc.h b/kernel/klibc.h old mode 100755 new mode 100644 diff --git a/kernel/multiboot.h b/kernel/multiboot.h index f8afac9..e3b3347 100644 --- a/kernel/multiboot.h +++ b/kernel/multiboot.h @@ -1,16 +1,16 @@ /* multiboot.h - the header for Multiboot */ /* Copyright (C) 1999 Free Software Foundation, Inc. - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ @@ -18,22 +18,22 @@ /* Macros. */ /* The magic number for the Multiboot header. */ -#define MULTIBOOT_HEADER_MAGIC 0x1BADB002 +#define MULTIBOOT_HEADER_MAGIC 0x1BADB002 /* The flags for the Multiboot header. */ -#define MULTIBOOT_HEADER_FLAGS 0x00010003 +#define MULTIBOOT_HEADER_FLAGS 0x00010003 /* The magic number passed by a Multiboot-compliant boot loader. */ -#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002 +#define MULTIBOOT_BOOTLOADER_MAGIC 0x2BADB002 /* The size of our stack (16KB). */ -#define STACK_SIZE 0x4000 +#define STACK_SIZE 0x4000 /* C symbol format. HAVE_ASM_USCORE is defined by configure. */ #ifdef HAVE_ASM_USCORE -# define EXT_C(sym) _ ## sym +# define EXT_C(sym) _ ## sym #else -# define EXT_C(sym) sym +# define EXT_C(sym) sym #endif #ifndef ASM diff --git a/test/check-build b/test/check-build index af96382..03b25d2 100755 --- a/test/check-build +++ b/test/check-build @@ -27,7 +27,7 @@ fi # Check that we have no tabs or trailing spaces in the source code # failure=0 -for dir in caca src cxx examples ruby tools; do +for dir in caca kernel src cxx examples ruby tools; do pushd ../$dir >/dev/null for x in $(make -s echo-sources); do case "$x" in @@ -56,7 +56,8 @@ fi # warnings="$(grep -c Warning: ../doc/doxygen.log)" if test "$warnings" != "0"; then - echo "error: $warnings warnings in Doxygen generation" + echo "error: $warnings warnings in Doxygen generation:" + grep Warning: ../doc/doxygen.log | sed 's/\(.\{75\}\)...*/\1 .../' ret=1 else echo "0 errors in documentation" diff --git a/win32/config.h b/win32/config.h index ab7dd0b..088c943 100644 --- a/win32/config.h +++ b/win32/config.h @@ -25,6 +25,7 @@ /* #undef HAVE_IMLIB2_H */ /* #undef HAVE_INTTYPES_H */ /* #undef HAVE_IOCTL */ +/* #undef HAVE_JNI_H */ /* #undef HAVE_LOCALE_H */ #define HAVE_MEMORY_H 1 /* #undef HAVE_NCURSESW_NCURSES_H */