[Libreoffice-commits] .: desktop/unx

David Tardon dtardon at kemper.freedesktop.org
Tue Oct 11 01:13:07 PDT 2011


 desktop/unx/source/pagein.c  |    2 -
 desktop/unx/source/splashx.c |   72 +++++++++++++++++++++++++------------------
 desktop/unx/source/start.c   |   46 ++++++++++++++++-----------
 3 files changed, 70 insertions(+), 50 deletions(-)

New commits:
commit 9317cad2508d344e416a13768029b24800101a4d
Author: David Tardon <dtardon at redhat.com>
Date:   Tue Oct 11 10:12:49 2011 +0200

    WaE: ISO C90 forbids mixed declarations and code

diff --git a/desktop/unx/source/pagein.c b/desktop/unx/source/pagein.c
index 90392b7..1e3f348 100755
--- a/desktop/unx/source/pagein.c
+++ b/desktop/unx/source/pagein.c
@@ -108,8 +108,8 @@ int pagein_execute (int argc, char **argv)
         if ((argv[i][0] == '@') && ((fp = fopen (argv[i], "r")) == 0))
         {
             char fullpath[4096];
+            char *path = NULL;
             memset(fullpath, 0, sizeof(fullpath));
-            char *path;
             strncpy (fullpath, argv[i] + 1, 3000);
             if (!(path = strrchr (fullpath, '/')))
                 path = fullpath;
diff --git a/desktop/unx/source/splashx.c b/desktop/unx/source/splashx.c
index 9f58f0c..0c7024d 100755
--- a/desktop/unx/source/splashx.c
+++ b/desktop/unx/source/splashx.c
@@ -253,15 +253,18 @@ static inline int BITS( unsigned long x )
 // Set 'bitmap' as the background of our 'win' window
 static void create_pixmap(struct splash* splash)
 {
+    Pixmap pixmap;
+    GC pixmap_gc;
+    unsigned long value_mask = 0;
+    XGCValues values;
+
     if ( !splash->bitmap_rows )
     {
         return;
     }
-    Pixmap pixmap = XCreatePixmap( splash->display, splash->win, splash->width, splash->height, splash->depth );
+    pixmap = XCreatePixmap( splash->display, splash->win, splash->width, splash->height, splash->depth );
 
-    unsigned long value_mask = 0;
-    XGCValues values;
-    GC pixmap_gc = XCreateGC( splash->display, pixmap, value_mask, &values );
+    pixmap_gc = XCreateGC( splash->display, pixmap, value_mask, &values );
 
     if ( splash->visual->class == TrueColor )
     {
@@ -298,6 +301,7 @@ static void create_pixmap(struct splash* splash)
 #endif
 
         char *data = malloc( splash->height * bytes_per_line );
+        char *out = data;
         image->data = data;
 
         // The following dithers & converts the color_t color to one
@@ -307,14 +311,17 @@ static void create_pixmap(struct splash* splash)
             int x, y; \
             for ( y = 0; y < splash->height; ++y ) \
             { \
-                out = data + y * bytes_per_line; \
                 unsigned long red_delta = 0, green_delta = 0, blue_delta = 0; \
                 color_t *in = (color_t *)(splash->bitmap_rows[y]);      \
+                out = data + y * bytes_per_line; \
                 for ( x = 0; x < splash->width; ++x, ++in  ) \
                 { \
                     unsigned long red   = in->r + red_delta; \
                     unsigned long green = in->g + green_delta; \
                     unsigned long blue  = in->b + blue_delta; \
+                    unsigned long pixel = 0; \
+                    uint32_t tmp = 0; \
+                    (void) tmp; \
                     red_delta = red & red_delta_mask; \
                     green_delta = green & green_delta_mask; \
                     blue_delta = blue & blue_delta_mask; \
@@ -324,7 +331,7 @@ static void create_pixmap(struct splash* splash)
                         green = 255; \
                     if ( blue > 255 ) \
                         blue = 255; \
-                    unsigned long pixel = \
+                    pixel = \
                         ( SHIFT( red, red_shift ) & red_mask ) | \
                         ( SHIFT( green, green_shift ) & green_mask ) | \
                         ( SHIFT( blue, blue_shift ) & blue_mask ); \
@@ -333,14 +340,12 @@ static void create_pixmap(struct splash* splash)
             } \
         }
 
-        char *out = data;
-
         if ( bpp == 32 )
         {
             if ( machine_byte_order == byte_order )
                 COPY_IN_OUT( 4, *( (uint32_t *)out ) = (uint32_t)pixel; out += 4; )
             else
-                COPY_IN_OUT( 4, uint32_t tmp = pixel;
+                COPY_IN_OUT( 4, tmp = pixel;
                              *( (uint8_t *)out     ) = *( (uint8_t *)(&tmp) + 3 );
                              *( (uint8_t *)out + 1 ) = *( (uint8_t *)(&tmp) + 2 );
                              *( (uint8_t *)out + 2 ) = *( (uint8_t *)(&tmp) + 1 );
@@ -352,13 +357,13 @@ static void create_pixmap(struct splash* splash)
             if ( machine_byte_order == byte_order && byte_order == LSBFirst )
                 COPY_IN_OUT( 3, *( (color_t *)out ) = *( (color_t *)( &pixel ) ); out += 3; )
             else if ( machine_byte_order == byte_order && byte_order == MSBFirst )
-                COPY_IN_OUT( 3, uint32_t tmp = pixel;
+                COPY_IN_OUT( 3, tmp = pixel;
                              *( (uint8_t *)out     ) = *( (uint8_t *)(&tmp) + 1 );
                              *( (uint8_t *)out + 1 ) = *( (uint8_t *)(&tmp) + 2 );
                              *( (uint8_t *)out + 2 ) = *( (uint8_t *)(&tmp) + 3 );
                              out += 3; )
             else
-                COPY_IN_OUT( 3, uint32_t tmp = pixel;
+                COPY_IN_OUT( 3, tmp = pixel;
                              *( (uint8_t *)out     ) = *( (uint8_t *)(&tmp) + 3 );
                              *( (uint8_t *)out + 1 ) = *( (uint8_t *)(&tmp) + 2 );
                              *( (uint8_t *)out + 2 ) = *( (uint8_t *)(&tmp) + 1 );
@@ -369,7 +374,7 @@ static void create_pixmap(struct splash* splash)
             if ( machine_byte_order == byte_order )
                 COPY_IN_OUT( 2, *( (uint16_t *)out ) = (uint16_t)pixel; out += 2; )
             else
-                COPY_IN_OUT( 2, uint16_t tmp = pixel;
+                COPY_IN_OUT( 2, tmp = pixel;
                              *( (uint8_t *)out     ) = *( (uint8_t *)(&tmp) + 1 );
                              *( (uint8_t *)out + 1 ) = *( (uint8_t *)(&tmp)     );
                              out += 2; );
@@ -469,6 +474,19 @@ static int splash_create_window( struct splash* splash, int argc, char** argv )
 {
     char *display_name = NULL;
     int i;
+    Window root_win;
+    int display_width = 0;
+    int display_height = 0;
+    unsigned long value_mask = 0;
+    XGCValues values;
+    const char* name = "LibreOffice";
+    const char* icon = "icon"; // FIXME
+    XSizeHints size_hints;
+#ifdef USE_XINERAMA
+    int n_xinerama_screens = 1;
+    XineramaScreenInfo* p_screens = NULL;
+#endif
+
     for ( i = 0; i < argc; i++ )
     {
         if ( !strcmp( argv[i], "-display" )  || !strcmp( argv[i], "--display" ) )
@@ -495,13 +513,12 @@ static int splash_create_window( struct splash* splash, int argc, char** argv )
     splash->color_map = DefaultColormap( splash->display, splash->screen );
     splash->visual = DefaultVisual( splash->display, splash->screen );
 
-    Window root_win = RootWindow( splash->display, splash->screen );
-    int display_width = DisplayWidth( splash->display, splash->screen );
-    int display_height = DisplayHeight( splash->display, splash->screen );
+    root_win = RootWindow( splash->display, splash->screen );
+    display_width = DisplayWidth( splash->display, splash->screen );
+    display_height = DisplayHeight( splash->display, splash->screen );
 
 #ifdef USE_XINERAMA
-    int n_xinerama_screens = 1;
-    XineramaScreenInfo* p_screens = XineramaQueryScreens( splash->display, &n_xinerama_screens );
+    p_screens = XineramaQueryScreens( splash->display, &n_xinerama_screens );
     if( p_screens )
     {
         int j = 0;
@@ -535,20 +552,14 @@ static int splash_create_window( struct splash* splash, int argc, char** argv )
     XAllocColor( splash->display, splash->color_map, &(splash->framecolor) );
 
     // not resizable, no decorations, etc.
-    unsigned long value_mask = 0;
-    XGCValues values;
     splash->gc = XCreateGC( splash->display, splash->win, value_mask, &values );
 
-    XSizeHints size_hints;
     size_hints.flags = PPosition | PSize | PMinSize | PMaxSize;
     size_hints.min_width = splash->width;
     size_hints.max_width = splash->width;
     size_hints.min_height = splash->height;
     size_hints.max_height = splash->height;
 
-    char* name = "LibreOffice";
-    char* icon = "icon"; // FIXME
-
     XSetStandardProperties( splash->display, splash->win, name, icon, None,
             0, 0, &size_hints );
 
@@ -651,6 +662,11 @@ static void splash_load_defaults( struct splash* splash, rtl_uString* pAppPath,
 {
     rtl_uString *pSettings = NULL, *pTmp = NULL;
     rtlBootstrapHandle handle;
+    int logo[1] =  { -1 },
+        bar[3] =   { -1, -1, -1 },
+        frame[3] = { -1, -1, -1 },
+        pos[2] =   { -1, -1 },
+        size[2] =  { -1, -1 };
 
     /* costruct the sofficerc file location */
     rtl_uString_newFromAscii( &pSettings, "file://" );
@@ -662,12 +678,6 @@ static void splash_load_defaults( struct splash* splash, rtl_uString* pAppPath,
     /* use it as the bootstrap file */
     handle = rtl_bootstrap_args_open( pSettings );
 
-    int logo[1] =  { -1 },
-        bar[3] =   { -1, -1, -1 },
-        frame[3] = { -1, -1, -1 },
-        pos[2] =   { -1, -1 },
-        size[2] =  { -1, -1 };
-
     /* get the values */
     get_bootstrap_value( logo,  1, handle, "Logo" );
     get_bootstrap_value( bar,   3, handle, "ProgressBarColor" );
@@ -692,6 +702,8 @@ static void splash_load_defaults( struct splash* splash, rtl_uString* pAppPath,
 // Draw the progress
 void splash_draw_progress( struct splash* splash, int progress )
 {
+    int length = 0;
+
     if (!splash)
     {
         return;
@@ -706,7 +718,7 @@ void splash_draw_progress( struct splash* splash, int progress )
         progress = 100;
     }
     // draw progress...
-    int length = ( progress * splash->barwidth / 100 ) - ( 2 * splash->barspace );
+    length = ( progress * splash->barwidth / 100 ) - ( 2 * splash->barspace );
     if ( length < 0 )
     {
         length = 0;
diff --git a/desktop/unx/source/start.c b/desktop/unx/source/start.c
index 2c07dce..c3f7f24 100755
--- a/desktop/unx/source/start.c
+++ b/desktop/unx/source/start.c
@@ -243,6 +243,12 @@ get_md5hash( rtl_uString *pText )
 {
     rtl_uString *pResult = NULL;
     sal_Int32 nCapacity = 100;
+    unsigned char *pData = NULL;
+    sal_uInt32 nSize = 0;
+    rtlDigest digest;
+    sal_uInt32 md5_key_len = 0;
+    sal_uInt8* md5_buf = NULL;
+    sal_uInt32 i = 0;
 
     if ( !pText )
         return NULL;
@@ -253,17 +259,17 @@ get_md5hash( rtl_uString *pText )
     rtl_string_release( pOut );
 #endif
 
-    unsigned char *pData = (unsigned char *)rtl_uString_getStr( pText );
-    sal_uInt32   nSize = rtl_uString_getLength( pText ) * sizeof( sal_Unicode );
+    pData = (unsigned char *)rtl_uString_getStr( pText );
+    nSize = rtl_uString_getLength( pText ) * sizeof( sal_Unicode );
     if ( !pData )
         return NULL;
 
-    rtlDigest digest = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
+    digest = rtl_digest_create( rtl_Digest_AlgorithmMD5 );
     if ( digest == 0 )
         return NULL;
 
-    sal_uInt32 md5_key_len = rtl_digest_queryLength( digest );
-    sal_uInt8 *md5_buf = (sal_uInt8 *)calloc( md5_key_len, sizeof( sal_uInt8 ) );
+    md5_key_len = rtl_digest_queryLength( digest );
+    md5_buf = (sal_uInt8 *)calloc( md5_key_len, sizeof( sal_uInt8 ) );
 
     rtl_digest_init( digest, pData , nSize );
     rtl_digest_update( digest, pData, nSize );
@@ -273,7 +279,6 @@ get_md5hash( rtl_uString *pText )
     /* create hex-value string from the MD5 value to keep
        the string size minimal */
     rtl_uString_new_WithLength( &pResult, nCapacity );
-    sal_uInt32 i = 0;
     for ( ; i < md5_key_len; ++i )
     {
         char val[3];
@@ -295,6 +300,9 @@ get_pipe_path( rtl_uString *pAppPath )
 {
     rtl_uString *pPath = NULL, *pTmp = NULL, *pUserInstallation = NULL;
     rtl_uString *pResult = NULL, *pBasePath = NULL, *pAbsUserInstallation = NULL;
+    rtlBootstrapHandle handle;
+    rtl_uString *pMd5hash = NULL;
+    sal_Unicode pUnicode[RTL_USTR_MAX_VALUEOFINT32];
 
     /* setup bootstrap filename */
     rtl_uString_newFromAscii( &pPath, "file://" );
@@ -306,7 +314,7 @@ get_pipe_path( rtl_uString *pAppPath )
     ustr_debug( "bootstap", pPath );
 
     /* read userinstallation value */
-    rtlBootstrapHandle handle = rtl_bootstrap_args_open( pPath );
+    handle = rtl_bootstrap_args_open( pPath );
 
     rtl_uString_newFromAscii( &pTmp, "UserInstallation" );
     rtl_bootstrap_get_from_handle( handle, pTmp, &pUserInstallation, NULL );
@@ -320,7 +328,7 @@ get_pipe_path( rtl_uString *pAppPath )
 
     /* create the pipe name */
     ustr_debug( "user installation", pAbsUserInstallation );
-    rtl_uString *pMd5hash = get_md5hash( pAbsUserInstallation );
+    pMd5hash = get_md5hash( pAbsUserInstallation );
     if ( !pMd5hash )
         rtl_uString_new( &pMd5hash );
 
@@ -332,7 +340,6 @@ get_pipe_path( rtl_uString *pAppPath )
     rtl_uString_newFromAscii( &pTmp, "/OSL_PIPE_" );
     rtl_uString_newConcat( &pResult, pResult, pTmp );
 
-    sal_Unicode pUnicode[RTL_USTR_MAX_VALUEOFINT32];
     rtl_ustr_valueOfInt32( pUnicode, (int)getuid(), 10 );
     rtl_uString_newFromStr( &pTmp, pUnicode );
     rtl_uString_newConcat( &pResult, pResult, pTmp );
@@ -395,11 +402,11 @@ escape_path( rtl_uString *pToEscape )
 {
     rtl_uString *pBuffer = NULL;
     sal_Int32 nCapacity = 1000;
+    sal_Int32 i = 0;
+    sal_Int32 nEscapeLength = rtl_uString_getLength( pToEscape );
 
     rtl_uString_new_WithLength( &pBuffer, nCapacity );
 
-    sal_Int32 i = 0;
-    sal_Int32 nEscapeLength = rtl_uString_getLength( pToEscape );
     for ( ; i < nEscapeLength; ++i )
     {
         sal_Unicode c = pToEscape->buffer[i];
@@ -440,6 +447,9 @@ send_args( int fd, rtl_uString *pCwdPath )
     sal_Bool bResult;
     size_t nLen;
     rtl_uString *pEscapedCwdPath = escape_path( pCwdPath );
+    sal_Bool bDontConvertNext = sal_False;
+    sal_uInt32 nArg = 0;
+    sal_uInt32 nArgCount = osl_getCommandArgCount();
 
     rtl_uString_new_WithLength( &pBuffer, nCapacity );
     rtl_uString_new( &pTmp );
@@ -463,11 +473,9 @@ send_args( int fd, rtl_uString *pCwdPath )
         rtl_uString_getLength( pBuffer ),
         RTL_CONSTASCII_STRINGPARAM( "0" ) );
 
-    sal_Bool bDontConvertNext = sal_False;
-    sal_uInt32 nArg;
-    sal_uInt32 nArgCount = osl_getCommandArgCount();
     for ( nArg = 0; nArg < nArgCount; ++nArg )
     {
+        rtl_uString *pEscapedTmp = NULL;
         rtl_uStringbuffer_insert_ascii( &pBuffer, &nCapacity,
                 rtl_uString_getLength( pBuffer ),
                 ",", 1 );
@@ -512,7 +520,7 @@ send_args( int fd, rtl_uString *pCwdPath )
         // (currently just -pt)
         bDontConvertNext = !rtl_ustr_ascii_compareIgnoreAsciiCase( pTmp->buffer, "-pt" );
 
-        rtl_uString *pEscapedTmp = escape_path( pTmp );
+        pEscapedTmp = escape_path( pTmp );
 
         rtl_uStringbuffer_insert( &pBuffer, &nCapacity,
                 rtl_uString_getLength( pBuffer ),
@@ -704,6 +712,10 @@ exec_javaldx (Args *args)
     rtl_uString **ppArgs;
     rtl_uString *pTmp, *pTmp2;
 
+    oslProcess javaldx = NULL;
+    oslFileHandle fileOut= 0;
+    oslProcessError err;
+
     ppArgs = (rtl_uString **)calloc( args->nArgsEnv + 2, sizeof( rtl_uString* ) );
 
     for ( nArgs = 0; nArgs < args->nArgsEnv; ++nArgs )
@@ -720,10 +732,6 @@ exec_javaldx (Args *args)
     rtl_uString_release (pTmp2);
     nArgs++;
 
-    oslProcess javaldx = NULL;
-    oslFileHandle fileOut= 0;
-    oslProcessError err;
-
     /* And also to javaldx */
     pApp = NULL;
     rtl_uString_newFromAscii( &pApp, "file://" );


More information about the Libreoffice-commits mailing list