Synchronize with trunk.
[reactos.git] / base / shell / cmd / dirstack.c
index b085324..9b749b6 100644 (file)
@@ -20,9 +20,9 @@
 
 typedef struct tagDIRENTRY
 {
-       struct tagDIRENTRY *prev;
-       struct tagDIRENTRY *next;
-       TCHAR szPath[1];
+    struct tagDIRENTRY *prev;
+    struct tagDIRENTRY *next;
+    TCHAR szPath[1];
 } DIRENTRY, *LPDIRENTRY;
 
 
@@ -34,42 +34,42 @@ static LPDIRENTRY lpStackBottom;
 static INT
 PushDirectory (LPTSTR pszPath)
 {
-       LPDIRENTRY lpDir = cmd_alloc(FIELD_OFFSET(DIRENTRY, szPath[_tcslen(pszPath) + 1]));
-       if (!lpDir)
-       {
-               error_out_of_memory ();
-               return -1;
-       }
-
-       lpDir->prev = NULL;
-       lpDir->next = lpStackTop;
-       if (lpStackTop == NULL)
-               lpStackBottom = lpDir;
-       else
-               lpStackTop->prev = lpDir;
-       lpStackTop = lpDir;
-
-       _tcscpy(lpDir->szPath, pszPath);
-
-       nStackDepth++;
-
-       return nErrorLevel = 0;
+    LPDIRENTRY lpDir = cmd_alloc(FIELD_OFFSET(DIRENTRY, szPath[_tcslen(pszPath) + 1]));
+    if (!lpDir)
+    {
+        error_out_of_memory ();
+        return -1;
+    }
+
+    lpDir->prev = NULL;
+    lpDir->next = lpStackTop;
+    if (lpStackTop == NULL)
+        lpStackBottom = lpDir;
+    else
+        lpStackTop->prev = lpDir;
+    lpStackTop = lpDir;
+
+    _tcscpy(lpDir->szPath, pszPath);
+
+    nStackDepth++;
+
+    return nErrorLevel = 0;
 }
 
 
 static VOID
 PopDirectory (VOID)
 {
-       LPDIRENTRY lpDir = lpStackTop;
-       lpStackTop = lpDir->next;
-       if (lpStackTop != NULL)
-               lpStackTop->prev = NULL;
-       else
-               lpStackBottom = NULL;
+    LPDIRENTRY lpDir = lpStackTop;
+    lpStackTop = lpDir->next;
+    if (lpStackTop != NULL)
+        lpStackTop->prev = NULL;
+    else
+        lpStackBottom = NULL;
 
-       cmd_free (lpDir);
+    cmd_free (lpDir);
 
-       nStackDepth--;
+    nStackDepth--;
 }
 
 
@@ -78,9 +78,9 @@ PopDirectory (VOID)
  */
 VOID InitDirectoryStack (VOID)
 {
-       nStackDepth = 0;
-       lpStackTop = NULL;
-       lpStackBottom = NULL;
+    nStackDepth = 0;
+    lpStackTop = NULL;
+    lpStackBottom = NULL;
 }
 
 
@@ -89,14 +89,14 @@ VOID InitDirectoryStack (VOID)
  */
 VOID DestroyDirectoryStack (VOID)
 {
-       while (nStackDepth)
-               PopDirectory ();
+    while (nStackDepth)
+        PopDirectory ();
 }
 
 
 INT GetDirectoryStackDepth (VOID)
 {
-       return nStackDepth;
+    return nStackDepth;
 }
 
 
@@ -105,23 +105,23 @@ INT GetDirectoryStackDepth (VOID)
  */
 INT CommandPushd (LPTSTR rest)
 {
-       TCHAR curPath[MAX_PATH];
+    TCHAR curPath[MAX_PATH];
 
-       if (!_tcsncmp (rest, _T("/?"), 2))
-       {
-               ConOutResPuts(STRING_DIRSTACK_HELP1);
-               return 0;
-       }
+    if (!_tcsncmp (rest, _T("/?"), 2))
+    {
+        ConOutResPuts(STRING_DIRSTACK_HELP1);
+        return 0;
+    }
 
-       GetCurrentDirectory (MAX_PATH, curPath);
+    GetCurrentDirectory (MAX_PATH, curPath);
 
-       if (rest[0] != _T('\0'))
-       {
-               if (!SetRootPath(NULL, rest))
-                       return 1;
-       }
+    if (rest[0] != _T('\0'))
+    {
+        if (!SetRootPath(NULL, rest))
+            return 1;
+    }
 
-       return PushDirectory(curPath);
+    return PushDirectory(curPath);
 }
 
 
@@ -130,20 +130,20 @@ INT CommandPushd (LPTSTR rest)
  */
 INT CommandPopd (LPTSTR rest)
 {
-       INT ret = 0;
-       if (!_tcsncmp(rest, _T("/?"), 2))
-       {
-               ConOutResPuts(STRING_DIRSTACK_HELP2);
-               return 0;
-       }
+    INT ret = 0;
+    if (!_tcsncmp(rest, _T("/?"), 2))
+    {
+        ConOutResPuts(STRING_DIRSTACK_HELP2);
+        return 0;
+    }
 
-       if (nStackDepth == 0)
-               return 1;
+    if (nStackDepth == 0)
+        return 1;
 
-       ret = _tchdir(lpStackTop->szPath) != 0;
-       PopDirectory ();
+    ret = _tchdir(lpStackTop->szPath) != 0;
+    PopDirectory ();
 
-       return ret;
+    return ret;
 }
 
 
@@ -152,31 +152,31 @@ INT CommandPopd (LPTSTR rest)
  */
 INT CommandDirs (LPTSTR rest)
 {
-       LPDIRENTRY lpDir;
+    LPDIRENTRY lpDir;
 
-       if (!_tcsncmp(rest, _T("/?"), 2))
-       {
-               ConOutResPuts(STRING_DIRSTACK_HELP3);
-               return 0;
-       }
+    if (!_tcsncmp(rest, _T("/?"), 2))
+    {
+        ConOutResPuts(STRING_DIRSTACK_HELP3);
+        return 0;
+    }
 
     nErrorLevel = 0;
 
-       lpDir = lpStackBottom;
+    lpDir = lpStackBottom;
 
-       if (lpDir == NULL)
-       {
-               ConOutResPuts(STRING_DIRSTACK_HELP4);
-               return 0;
-       }
+    if (lpDir == NULL)
+    {
+        ConOutResPuts(STRING_DIRSTACK_HELP4);
+        return 0;
+    }
 
-       while (lpDir != NULL)
-       {
-               ConOutPuts(lpDir->szPath);
-               lpDir = lpDir->prev;
-       }
+    while (lpDir != NULL)
+    {
+        ConOutPuts(lpDir->szPath);
+        lpDir = lpDir->prev;
+    }
 
-       return 0;
+    return 0;
 }
 
 #endif /* FEATURE_DIRECTORY_STACK */