summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorPierre-André Jacquod <pjacquod@alumni.ethz.ch>2011-10-02 17:57:05 +0200
committerPierre-André Jacquod <pjacquod@alumni.ethz.ch>2011-10-07 15:57:49 +0200
commit5f6c37b1ebd5c77311b5474e1243091faf147244 (patch)
treed0cc432cdd6a1d4ecb70db84f8f051820483cde9 /shell
parentb88e1f5cd1f1a5f963240bf9ed4e2a05f17a7511 (diff)
cppcheck reduce scope of var in shell/...gconfaccess.cxx
Diffstat (limited to 'shell')
-rw-r--r--shell/source/backends/gconfbe/gconfaccess.cxx152
1 files changed, 70 insertions, 82 deletions
diff --git a/shell/source/backends/gconfbe/gconfaccess.cxx b/shell/source/backends/gconfbe/gconfaccess.cxx
index 9b93c737cd2e..e3190a0f7d2a 100644
--- a/shell/source/backends/gconfbe/gconfaccess.cxx
+++ b/shell/source/backends/gconfbe/gconfaccess.cxx
@@ -109,7 +109,6 @@ static OUString xdg_user_dir_lookup (const char *type)
{
char *config_home;
char *p;
- int relative;
bool bError = false;
osl::Security aSecurity;
@@ -121,112 +120,101 @@ static OUString xdg_user_dir_lookup (const char *type)
if (!aSecurity.getHomeDir( aHomeDirURL ) )
{
- osl::FileBase::getFileURLFromSystemPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/tmp")), aDocumentsDirURL);
- return aDocumentsDirURL;
+ osl::FileBase::getFileURLFromSystemPath(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/tmp")), aDocumentsDirURL);
+ return aDocumentsDirURL;
}
config_home = getenv ("XDG_CONFIG_HOME");
if (config_home == NULL || config_home[0] == 0)
{
- aConfigFileURL = OUString(aHomeDirURL);
- aConfigFileURL += OUString(RTL_CONSTASCII_USTRINGPARAM("/.config/user-dirs.dirs"));
+ aConfigFileURL = OUString(aHomeDirURL);
+ aConfigFileURL += OUString(RTL_CONSTASCII_USTRINGPARAM("/.config/user-dirs.dirs"));
}
else
{
- aConfigFileURL = OUString::createFromAscii(config_home);
- aConfigFileURL += OUString(RTL_CONSTASCII_USTRINGPARAM("/user-dirs.dirs"));
+ aConfigFileURL = OUString::createFromAscii(config_home);
+ aConfigFileURL += OUString(RTL_CONSTASCII_USTRINGPARAM("/user-dirs.dirs"));
}
if(osl_File_E_None == osl_openFile(aConfigFileURL.pData, &handle, osl_File_OpenFlag_Read))
{
- rtl::ByteSequence seq;
- while (osl_File_E_None == osl_readLine(handle , (sal_Sequence **)&seq))
- {
- /* Remove newline at end */
- int len = seq.getLength();
- if(len>0 && seq[len-1] == '\n')
- seq[len-1] = 0;
-
- p = (char *)seq.getArray();
-
- while (*p == ' ' || *p == '\t')
- p++;
-
- if (strncmp (p, "XDG_", 4) != 0)
- continue;
- p += 4;
- if (strncmp (p, type, strlen (type)) != 0)
- continue;
- p += strlen (type);
- if (strncmp (p, "_DIR", 4) != 0)
- continue;
- p += 4;
-
- while (*p == ' ' || *p == '\t')
- p++;
-
- if (*p != '=')
- continue;
- p++;
-
- while (*p == ' ' || *p == '\t')
- p++;
-
- if (*p != '"')
- continue;
- p++;
-
- relative = 0;
- if (strncmp (p, "$HOME/", 6) == 0)
- {
- p += 6;
- relative = 1;
- }
- else if (*p != '/')
- continue;
-
- if (relative)
- {
- aUserDirBuf = OUStringBuffer(aHomeDirURL);
- aUserDirBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/" ) );
- }
- else
- {
- aUserDirBuf = OUStringBuffer();
- }
-
- while (*p && *p != '"')
+ rtl::ByteSequence seq;
+ while (osl_File_E_None == osl_readLine(handle , (sal_Sequence **)&seq))
{
- if ((*p == '\\') && (*(p+1) != 0))
+ /* Remove newline at end */
+ int relative = 0;
+ int len = seq.getLength();
+ if(len>0 && seq[len-1] == '\n')
+ seq[len-1] = 0;
+
+ p = (char *)seq.getArray();
+ while (*p == ' ' || *p == '\t')
+ p++;
+ if (strncmp (p, "XDG_", 4) != 0)
+ continue;
+ p += 4;
+ if (strncmp (p, type, strlen (type)) != 0)
+ continue;
+ p += strlen (type);
+ if (strncmp (p, "_DIR", 4) != 0)
+ continue;
+ p += 4;
+ while (*p == ' ' || *p == '\t')
+ p++;
+ if (*p != '=')
+ continue;
p++;
- aUserDirBuf.append((sal_Unicode)*p++);
- }
- }
- osl_closeFile(handle);
+ while (*p == ' ' || *p == '\t')
+ p++;
+ if (*p != '"')
+ continue;
+ p++;
+ if (strncmp (p, "$HOME/", 6) == 0)
+ {
+ p += 6;
+ relative = 1;
+ }
+ else if (*p != '/')
+ continue;
+ if (relative)
+ {
+ aUserDirBuf = OUStringBuffer(aHomeDirURL);
+ aUserDirBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/" ) );
+ }
+ else
+ {
+ aUserDirBuf = OUStringBuffer();
+ }
+ while (*p && *p != '"')
+ {
+ if ((*p == '\\') && (*(p+1) != 0))
+ p++;
+ aUserDirBuf.append((sal_Unicode)*p++);
+ }
+ }//end of while
+ osl_closeFile(handle);
}
else
- bError = true;
-
+ bError = true;
if (aUserDirBuf.getLength()>0 && !bError)
{
- aDocumentsDirURL = aUserDirBuf.makeStringAndClear();
- osl::Directory aDocumentsDir( aDocumentsDirURL );
- if( osl::FileBase::E_None == aDocumentsDir.open() )
- return aDocumentsDirURL;
+ aDocumentsDirURL = aUserDirBuf.makeStringAndClear();
+ osl::Directory aDocumentsDir( aDocumentsDirURL );
+ if( osl::FileBase::E_None == aDocumentsDir.open() )
+ return aDocumentsDirURL;
}
-
/* Special case desktop for historical compatibility */
if (strcmp (type, "DESKTOP") == 0)
{
- aUserDirBuf = OUStringBuffer(aHomeDirURL);
- aUserDirBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/Desktop" ) );
- return aUserDirBuf.makeStringAndClear();
+ aUserDirBuf = OUStringBuffer(aHomeDirURL);
+ aUserDirBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/Desktop" ) );
+ return aUserDirBuf.makeStringAndClear();
}
else
{
- aUserDirBuf = OUStringBuffer(aHomeDirURL);
- aUserDirBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/Documents" ) );
- return aUserDirBuf.makeStringAndClear();
+ aUserDirBuf = OUStringBuffer(aHomeDirURL);
+ aUserDirBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "/Documents" ) );
+ return aUserDirBuf.makeStringAndClear();
}
}