gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] /srv/bzr/gnash/trunk r10029: Remove dead code from config


From: Benjamin Wolsey
Subject: [Gnash-commit] /srv/bzr/gnash/trunk r10029: Remove dead code from configure.ac, make file type magic a bit clearer.
Date: Tue, 21 Oct 2008 08:53:18 +0200
User-agent: Bazaar (1.5)

------------------------------------------------------------
revno: 10029
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Tue 2008-10-21 08:53:18 +0200
message:
  Remove dead code from configure.ac, make file type magic a bit clearer.
modified:
  configure.ac
  libcore/impl.cpp
    ------------------------------------------------------------
    revno: 10023.1.1
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Mon 2008-10-20 20:35:08 +0200
    message:
      Drop some unused and probably useless parts of configure.ac
    modified:
      configure.ac
    ------------------------------------------------------------
    revno: 10023.1.2
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Mon 2008-10-20 21:01:11 +0200
    message:
      Cache value correctly.
    modified:
      configure.ac
    ------------------------------------------------------------
    revno: 10023.1.3
    committer: Benjamin Wolsey <address@hidden>
    branch nick: work
    timestamp: Mon 2008-10-20 22:00:32 +0200
    message:
      Use bjacques' good way of comparing char arrays to simplify filetype
      identification.
    modified:
      libcore/impl.cpp
=== modified file 'configure.ac'
--- a/configure.ac      2008-10-20 16:45:27 +0000
+++ b/configure.ac      2008-10-20 19:01:11 +0000
@@ -184,53 +184,6 @@
 AM_CONDITIONAL(HAS_GETTEXT, test x$ac_cv_path_XGETTEXT != x)
 dnl AM_GNU_GETTEXT_VERSION(0.15)
 
-dnl We shouldn't need SIZET_FMT anywhere anymore, so all of this
-dnl is useless.
-
-dnl AC_CHECK_SIZEOF([size_t], 4, AC_INCLUDES_DEFAULT)
-
-dnl AC_DEFINE(SIZET_FMT, ["%z"], [size_t printf modifier is z])
-
-dnl NOTE: Using AC_TRY_COMPILE is bogus when cross-compiling !
-dnl       We need to know the size of size_t in the *target* host, 
-dnl       not the build host (right?)
-dnl
-dnl AC_LANG_PUSH(C++)
-dnl if test "$GXX" = yes; then
-dnl save_CXXFLAGS="$CXXFLAGS"
-dnl CXXFLAGS="$CXXFLAGS -Werror -Wformat"
-dnl fi
-
-dnl AC_TRY_COMPILE([#include <sys/types.h>
-dnl   #include <stdio.h>], [
-dnl   size_t num = 0;
-dnl   printf("%d", num); ],
-dnl   AC_DEFINE(SIZET_FMT, ["%d"], [size_t printf modifier is d]), [
-
-dnl AC_TRY_COMPILE([#include <sys/types.h>
-dnl   #include <stdio.h>], [
-dnl   size_t num = 0;
-dnl   printf("%u", num); ],
-dnl   AC_DEFINE(SIZET_FMT, ["%u"], [size_t printf modifier is u]), [
-
-dnl AC_TRY_COMPILE([#include <sys/types.h>
-dnl   #include <stdio.h>], [
-dnl   size_t num = 0;
-dnl   printf("%lu", num); ],
-dnl   AC_DEFINE(SIZET_FMT, ["%lu"], [size_t printf modifier is lu]), [
-
-dnl AC_TRY_COMPILE([#include <sys/types.h> 
-dnl   #include <stdio.h>], [
-dnl   size_t num = 0;
-dnl   printf("%ld", num); ],
-dnl   AC_DEFINE(SIZET_FMT, ["%ld"], [size_t printf modifier is ld])
-dnl )])])])
-
-dnl if test "$GXX" = yes; then
-dnl CXXFLAGS="$save_CXXFLAGS"
-dnl fi
-dnl AC_LANG_POP(C++)
-
 dnl This is primarily used when compiling for a similar architecture,
 dnl like pentium->geode, which can use the same compiler, but have
 dnl different development libraries.
@@ -278,7 +231,7 @@
   *)   AC_MSG_ERROR([bad value ${enableval} for --enable-jemalloc option]) ;;
 esac],jemalloc=no)
 
-dnl There is some weird stuff going on with NetBSD and jemalloc, so don't 
built it for now.
+dnl There is some weird stuff going on with NetBSD and jemalloc, so don't 
build it for now.
 if test x"${netbsd}" = x"yes"; then
   jemalloc=no
 fi
@@ -587,12 +540,6 @@
 build_cairo=no
 AC_ARG_ENABLE(renderer,
   AC_HELP_STRING([--enable-renderer=], [Use the specified GUI toolkit 
(default=ogl,agg)]),
-dnl  if test -n ${enableval}; then
-dnl    add_renderer="${enableval}"
-dnl    enableval=`echo ${enableval} | tr '\054' ' ' `
-dnl  fi
-dnl  while test -n "${enableval}" ; do
-dnl    val=`echo ${enableval} | cut -d ' ' -f 1`
     [case "${enableval}" in
       ogl|OGL|gl|GL|opengl|OPENGL|OpenGL)
         build_ogl=yes
@@ -617,19 +564,8 @@
       esac],
        build_agg=yes
        add_renderer=agg
-dnl    enableval=`echo ${enableval} | cut -d ' ' -f 2-6`
-dnl    if test x$val = x$enableval; then
-dnl      break;
-dnl    fi
-dnl  done
 )
 
-dnl if test x$add_renderer = x; then
-dnl    build_ogl=yes
-dnl    build_agg=yes
-dnl    add_renderer="ogl,agg"
-dnl fi
-
 if test x$build_ogl = xyes; then
   if test x$build_fb = xyes; then
     AC_MSG_ERROR([OpenGL renderer is not supported by FB gui. Use 
--enable-renderer=AGG or --enable-gui=kde,gtk,sdl]);
@@ -1359,13 +1295,8 @@
 AC_CHECK_HEADERS(unistd.h)
 AC_CHECK_HEADERS(sys/time.h)
 AC_CHECK_LIB(lber, ber_free)
-dnl AC_CHECK_LIB(m, sqrt)
 AC_CHECK_LIB(c, getpwnam, AC_DEFINE(HAVE_GETPWNAM, 1, [Has getpwnam] ))
 
-dnl AC_CHECK_LIB(m, exp2, AC_DEFINE(HAVE_EXP2, 1, [Has exp2()]))
-dnl AC_CHECK_LIB(m, log2, AC_DEFINE(HAVE_LOG2, 1, [Has log2()]))
-dnl AC_CHECK_LIB(m, trunc, AC_DEFINE(HAVE_TRUNC, 1, [Has trunc()]))
-
 dnl X11 is needed for fltk (at least),
 dnl and probably for many other guis too ...
 dnl if ! test x$build_fb = xyes; then # <--- this is wrong as build_x is 
non-exclusive
@@ -1526,31 +1457,16 @@
 AC_CHECK_FUNCS(sysconf)
 AC_CHECK_FUNCS(shmget shmat shmdt mmap)
 AC_CHECK_FUNCS(memmove)
-AC_CHECK_FUNC(strndup, AC_DEFINE(HAVE_STRNDUP, 1, [Has strndup()] ))
+dnl AC_CHECK_FUNC(strndup, AC_DEFINE(HAVE_STRNDUP, 1, [Has strndup()] ))
 AC_CHECK_FUNC(clock_gettime, AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Has 
clock_gettime()] ))
-AC_CHECK_FUNCS(strlcpy, AC_DEFINE(HAVE_STRLCPY_PROTO, [1],[Define if you have 
the strlcpy prototype]))
-AC_CHECK_FUNCS(strlcat, AC_DEFINE(HAVE_STRLCAT_PROTO, [1],[Define if you have 
the strlcat prototype]))
+dnl AC_CHECK_FUNCS(strlcpy, AC_DEFINE(HAVE_STRLCPY_PROTO, [1],[Define if you 
have the strlcpy prototype]))
+dnl AC_CHECK_FUNCS(strlcat, AC_DEFINE(HAVE_STRLCAT_PROTO, [1],[Define if you 
have the strlcat prototype]))
 dnl Look for Win32 networking stuff
 AC_CHECK_HEADERS(winsock.h)
 AC_CHECK_HEADERS(winsock2.h)
 AC_CHECK_FUNCS(socket)
 AC_CHECK_FUNCS(CreateFileMappingA)
 
-dnl GNASH_HASHMAP
-dnl Let's get rid of this small file and inline the function.
-
-dnl AC_LANG_PUSH(C++)
-dnl    AC_CHECK_HEADER(ext/hash_map, [
-dnl            AC_DEFINE([GNU_HASH_MAP], [1], [Using GNU ext/hash_map.h])
-dnl            AC_DEFINE([HASH_MAP_NS], [__gnu_cxx], [Using GNU __gnu_cxx::])
-dnl    ], [
-dnl            AC_CHECK_HEADER(hash_map, [
-dnl                    AC_DEFINE([WIN32_HASH_MAP], [1], [Using Win32 
hash_map.h])
-dnl                    AC_DEFINE([HASH_MAP_NS], [stdext], [Using win32 
stdext::])
-dnl            ])
-dnl    ])
-dnl AC_LANG_POP(C++)
-
 dnl Shm::resize() uses this if it exists
 AC_CHECK_LIB(c, mremap)
 
@@ -2033,7 +1949,7 @@
 dnl /* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19664 */
 AC_DEFUN([CHECK_VISIBILITY_GCC_BUG],
   [
-    AC_CACHE_CHECK([if -fvisibility-inlines-hidden is broken], 
gcc_visibility_bug, [
+    AC_CACHE_CHECK([if -fvisibility-inlines-hidden is broken], 
ac_cv_gcc_visibility_bug, [
         AC_LANG_PUSH(C++)
         save_CXXFLAGS=$CXXFLAGS
         save_LDFLAGS=$LDFLAGS
@@ -2058,14 +1974,14 @@
             return 0;
           }
         ], [],
-        gcc_visibility_bug=no, gcc_visibility_bug=yes)
+        ac_cv_gcc_visibility_bug=no, ac_cv_gcc_visibility_bug=yes)
 
         CXXFLAGS=$save_CXXFLAGS
         LDFLAGS=$save_LDFLAGS
         AC_LANG_POP(C++)
       ]
     )
-    if test x$gcc_visibility_bug = xno; then
+    if test x$ac_cv_gcc_visibility_bug = xno; then
       CXXFLAGS="$CXXFLAGS -fvisibility-inlines-hidden"
       if test x"$enable_visibility" != x"no"; then
         CXXFLAGS="$CXXFLAGS -fvisibility=hidden"

=== modified file 'libcore/impl.cpp'
--- a/libcore/impl.cpp  2008-09-17 07:16:12 +0000
+++ b/libcore/impl.cpp  2008-10-20 20:00:32 +0000
@@ -278,59 +278,57 @@
 
 }
 
-// Get type of file looking at first bytes
-// return "jpeg", "png", "swf" or "unknown"
-//
+/// Get type of file looking at first bytes
 FileType
 getFileType(IOChannel* in)
 {
   in->seek(0);
 
-  unsigned char buf[3];
+  char buf[3];
   
-  if ( 3 < in->read(buf, 3) )
+  if (3 < in->read(buf, 3))
   {
     log_error(_("Can't read file header"));
     in->seek(0);
     return GNASH_FILETYPE_UNKNOWN;
   }
   
-  // This is the magic number for any JPEG format file
-  if ((buf[0] == 0xff) && (buf[1] == 0xd8) && (buf[2] == 0xff))
+  // This is the magic number {0xff, 0xd8, 0xff} for JPEG format files
+  if (std::equal(buf, buf + 3, "\xff\xd8\xff"))
   {
     in->seek(0);
     return GNASH_FILETYPE_JPEG;
   }
 
   // This is the magic number for any PNG format file
-  if ((buf[0] == 137) && (buf[1] == 'P') && (buf[2] == 'N')) // buf[3] == 'G' 
(we didn't read so far)
+  // buf[3] == 'G' (we didn't read so far)
+  if (std::equal(buf, buf + 3, "\x89PN")) 
   {
     in->seek(0);
     return GNASH_FILETYPE_PNG;
   }
 
   // This is the magic number for any GIF format file
-  if ((buf[0] == 'G') && (buf[1] == 'I') && (buf[2] == 'F'))
+  if (std::equal(buf, buf + 3, "GIF"))
   {
     in->seek(0);
     return GNASH_FILETYPE_GIF;
   }
 
   // This is for SWF (FWS or CWS)
-  if (  (buf[0] == 'F' || buf[0] == 'C') &&
-    (buf[1] == 'W') &&
-    (buf[2] == 'S') )
+  if (std::equal(buf, buf + 3, "FWS") || std::equal(buf, buf + 3, "CWS"))
   {
     in->seek(0);
     return GNASH_FILETYPE_SWF;
   }
 
-  if ((buf[0] == 'F') && (buf[1] == 'L') && (buf[2] == 'V') ) {
+  // Take one guess at what this is. (It's an FLV-format file).
+  if (std::equal(buf, buf + 3, "FLV")) {
     return GNASH_FILETYPE_FLV;
   }
   
   // Check if it is an swf embedded in a player (.exe-file)
-  if ((buf[0] == 'M') && (buf[1] == 'Z')) {
+  if (std::equal(buf, buf + 2, "MZ")) {
 
     if ( 3 < in->read(buf, 3) )
     {


reply via email to

[Prev in Thread] Current Thread [Next in Thread]