changeset 35521:baf53d200292

Avoid using local variables named filename. This is the name of a global MPlayer variable. Avoiding it avoids confusion.
author ib
date Wed, 05 Dec 2012 23:28:14 +0000
parents ecbaf301748f
children 92809c17fc9d
files gui/cfg.c gui/cfg.h gui/ui/gtk/fileselect.c gui/ui/main.c gui/win32/dialogs.c gui/win32/gui.c gui/win32/gui.h gui/win32/interface.c
diffstat 8 files changed, 45 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/gui/cfg.c	Wed Dec 05 23:12:53 2012 +0000
+++ b/gui/cfg.c	Wed Dec 05 23:28:14 2012 +0000
@@ -233,11 +233,11 @@
     { NULL,                          NULL,                     0,                     0,           0,     0,          NULL }
 };
 
-int cfg_gui_include(m_option_t *conf, const char *filename)
+int cfg_gui_include(m_option_t *conf, const char *file)
 {
     (void)conf;
 
-    return m_config_parse_config_file(gui_conf, filename, 0);
+    return m_config_parse_config_file(gui_conf, file, 0);
 }
 
 void cfg_read(void)
--- a/gui/cfg.h	Wed Dec 05 23:12:53 2012 +0000
+++ b/gui/cfg.h	Wed Dec 05 23:28:14 2012 +0000
@@ -89,7 +89,7 @@
 
 extern char *fsHistory[5];
 
-int cfg_gui_include(m_option_t *conf, const char *filename);
+int cfg_gui_include(m_option_t *conf, const char *file);
 void cfg_read(void);
 void cfg_write(void);
 
--- a/gui/ui/gtk/fileselect.c	Wed Dec 05 23:12:53 2012 +0000
+++ b/gui/ui/gtk/fileselect.c	Wed Dec 05 23:28:14 2012 +0000
@@ -172,13 +172,13 @@
 static void clist_append_fname(GtkWidget * list, char *fname,
                                GdkPixmap *pixmap, GdkPixmap *mask) {
   gint pos;
-  gchar *filename, *str[2];
-  filename = g_filename_to_utf8(fname, -1, NULL, NULL, NULL);
+  gchar *filename_utf8, *str[2];
+  filename_utf8 = g_filename_to_utf8(fname, -1, NULL, NULL, NULL);
   str[0] = NULL;
-  str[1] = filename ? filename : fname;
+  str[1] = filename_utf8 ? filename_utf8 : fname;
   pos = gtk_clist_append(GTK_CLIST(list), str);
   gtk_clist_set_pixmap(GTK_CLIST(list), pos, 0, pixmap, mask);
-  g_free(filename);
+  g_free(filename_utf8);
 }
 
 static void CheckDir( GtkWidget * list )
--- a/gui/ui/main.c	Wed Dec 05 23:12:53 2012 +0000
+++ b/gui/ui/main.c	Wed Dec 05 23:28:14 2012 +0000
@@ -591,7 +591,7 @@
   int f = 0;
 
   char* subtitles = NULL;
-  char* filename = NULL;
+  char* file = NULL;
   char* s;
 
   if (num <= 0)
@@ -627,8 +627,8 @@
       }
 
       /* clear playlist */
-      if (filename == NULL) {
-	filename = files[f];
+      if (file == NULL) {
+	file = files[f];
 	listMgr(PLAYLIST_DELETE,0);
       }
 
@@ -654,8 +654,8 @@
     free( str );
   }
 
-  if (filename) {
-    uiSetFile( NULL,filename,STREAMTYPE_FILE );
+  if (file) {
+    uiSetFile( NULL,file,STREAMTYPE_FILE );
     if ( guiInfo.Playing == GUI_PLAY ) uiEventHandling( evStop,0 );
     uiEventHandling( evPlay,0 );
   }
--- a/gui/win32/dialogs.c	Wed Dec 05 23:12:53 2012 +0000
+++ b/gui/win32/dialogs.c	Wed Dec 05 23:28:14 2012 +0000
@@ -90,7 +90,7 @@
     OPENFILENAME fileopen;
     int result = 0;
     char filelist[MAXFILE];
-    char filename[MAX_PATH];
+    char file[MAX_PATH];
     char directory[MAX_PATH];
     char *filespec = NULL;
     char *filepart = NULL;
@@ -127,24 +127,24 @@
         do
         {
             filespec = &fileopen.lpstrFile[fileopen.nFileOffset];
-            strcpy(filename, directory);
+            strcpy(file, directory);
 
             if (*filespec)
             {
-                strcat(filename, "/");
-                strcat(filename, filespec);
+                strcat(file, "/");
+                strcat(file, filespec);
             }
 
-            if (GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY)
-                mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] %s is a directory, skipping...\n", filename);
+            if (GetFileAttributes(file) & FILE_ATTRIBUTE_DIRECTORY)
+                mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] %s is a directory, skipping...\n", file);
             else
             {
-                if (GetFullPathName(filename, MAX_PATH, filename, &filepart))
+                if (GetFullPathName(file, MAX_PATH, file, &filepart))
                 {
-                    uiSetFile(NULL, filename, STREAMTYPE_FILE);
-                    if(!parse_filename(filename, playtree, mconfig, 0))
-                        gui->playlist->add_track(gui->playlist, filename, NULL, filepart, 0);
-                    mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding file: %s - path %s\n", filespec, filename);
+                    uiSetFile(NULL, file, STREAMTYPE_FILE);
+                    if(!parse_filename(file, playtree, mconfig, 0))
+                        gui->playlist->add_track(gui->playlist, file, NULL, filepart, 0);
+                    mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding file: %s - path %s\n", filespec, file);
                     result++;
                 }
             }
--- a/gui/win32/gui.c	Wed Dec 05 23:12:53 2012 +0000
+++ b/gui/win32/gui.c	Wed Dec 05 23:28:14 2012 +0000
@@ -166,21 +166,21 @@
     }
 }
 
-void capitalize(char *filename)
+void capitalize(char *fname)
 {
     unsigned int i;
     BOOL cap = TRUE;
-    for (i=0; i < strlen(filename); i++)
+    for (i=0; i < strlen(fname); i++)
     {
         if (cap)
         {
             cap = FALSE;
-            filename[i] = toupper(filename[i]);
+            fname[i] = toupper(fname[i]);
         }
-        else if (filename[i] == ' ')
+        else if (fname[i] == ' ')
             cap = TRUE;
         else
-            filename[i] = tolower(filename[i]);
+            fname[i] = tolower(fname[i]);
     }
 }
 static void display_about_box(HWND hWnd)
@@ -1040,7 +1040,7 @@
             {
                 char device[MAX_PATH];
                 char searchpath[MAX_PATH];
-                char filename[MAX_PATH];
+                char file[MAX_PATH];
                 int len, pos = 0, cdromdrive = 0;
                 len = GetLogicalDriveStrings(MAX_PATH, device);
                 while(pos < len)
@@ -1074,8 +1074,8 @@
                                     gui->playlist->clear_playlist(gui->playlist);
                                     do
                                     {
-                                        sprintf(filename, "%smpegav/%s", device + pos, finddata.cFileName);
-                                        gui->playlist->add_track(gui->playlist, filename, NULL, NULL, 0);
+                                        sprintf(file, "%smpegav/%s", device + pos, finddata.cFileName);
+                                        gui->playlist->add_track(gui->playlist, file, NULL, NULL, 0);
                                     }
                                     while(FindNextFile(searchhndl, &finddata));
                                     FindClose(searchhndl);
--- a/gui/win32/gui.h	Wed Dec 05 23:12:53 2012 +0000
+++ b/gui/win32/gui.h	Wed Dec 05 23:28:14 2012 +0000
@@ -102,7 +102,7 @@
 int create_window(gui_t *gui, char *skindir);
 int create_videowindow(gui_t *gui);
 int parse_filename(char *file, play_tree_t *playtree, m_config_t *mconfig, int clear);
-void capitalize(char *filename);
+void capitalize(char *fname);
 LPSTR acp(LPCSTR utf8);
 
 void renderinfobox(skin_t *skin, window_priv_t *priv);
--- a/gui/win32/interface.c	Wed Dec 05 23:12:53 2012 +0000
+++ b/gui/win32/interface.c	Wed Dec 05 23:28:14 2012 +0000
@@ -95,16 +95,16 @@
  *
  * @return pointer to the converted file path
  */
-static char *unix_name (char *filename)
+static char *unix_name (char *win_filename)
 {
     static char *unix_filename;
     LPSTR (*CDECL wine_get_unix_file_name_ptr)(LPCWSTR);
     int wchar_conv;
 
-    if (*filename && (filename[1] == ':'))
+    if (*win_filename && (win_filename[1] == ':'))
     {
         wine_get_unix_file_name_ptr = (void *) GetProcAddress(GetModuleHandleA("KERNEL32"), "wine_get_unix_file_name");
-        wchar_conv = MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, NULL, 0);
+        wchar_conv = MultiByteToWideChar(CP_UNIXCP, 0, win_filename, -1, NULL, 0);
 
         if (wine_get_unix_file_name_ptr && wchar_conv)
         {
@@ -112,16 +112,16 @@
             char *unix_name;
 
             ntpath = HeapAlloc(GetProcessHeap(), 0, sizeof(*ntpath) * (wchar_conv + 1));
-            MultiByteToWideChar(CP_UNIXCP, 0, filename, -1, ntpath, wchar_conv);
+            MultiByteToWideChar(CP_UNIXCP, 0, win_filename, -1, ntpath, wchar_conv);
             unix_name = wine_get_unix_file_name_ptr(ntpath);
             setdup(&unix_filename, unix_name);
-            filename = unix_filename;
+            win_filename = unix_filename;
             HeapFree(GetProcessHeap(), 0, unix_name);
             HeapFree(GetProcessHeap(), 0, ntpath);
         }
     }
 
-    return filename;
+    return win_filename;
 }
 
 /**
@@ -818,8 +818,8 @@
 /* This function adds/inserts one file into the gui playlist */
 static int import_file_into_gui(char *pathname, int insert)
 {
-    char filename[MAX_PATH];
-    char *filepart = filename;
+    char file[MAX_PATH];
+    char *filepart = file;
 
     if (strstr(pathname, "://"))
     {
@@ -827,16 +827,16 @@
         mygui->playlist->add_track(mygui->playlist, pathname, NULL, NULL, 0);
         return 1;
     }
-    if (GetFullPathName(pathname, MAX_PATH, filename, &filepart))
+    if (GetFullPathName(pathname, MAX_PATH, file, &filepart))
     {
-        if (!(GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY))
+        if (!(GetFileAttributes(file) & FILE_ATTRIBUTE_DIRECTORY))
         {
-            mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding filename: %s - fullpath: %s\n", filepart, filename);
-            mygui->playlist->add_track(mygui->playlist, filename, NULL, filepart, 0);
+            mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding filename: %s - fullpath: %s\n", filepart, file);
+            mygui->playlist->add_track(mygui->playlist, file, NULL, filepart, 0);
             return 1;
         }
         else
-            mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Cannot add %s\n", filename);
+            mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Cannot add %s\n", file);
     }
 
     return 0;