]> git.sur5r.net Git - cc65/blobdiff - testcode/lib/rename-test.c
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / testcode / lib / rename-test.c
index 67785258dac40de30770da1974231e0348bd3627..0e9160b9e752113d8c135100cb44f82af2deac8a 100644 (file)
@@ -20,36 +20,36 @@ int main(void)
     /* Generate two temporary file-names that have a random, unused spelling. */
     _randomize();
     for (;;) {
-       r = rand();
-       sprintf(name1, "r%04.4u.1", (unsigned)r);
-       sprintf(name2, "r%04.4u.2", (unsigned)r);
-
-       /* Ensure that neither file-name exists. */
-       errno = 0;
-       file = fopen(name1, "r");
-       if (file != NULL) {
-           fclose(file);
-           continue;                   /* try a different spelling */
-       }
-
-       /* Make sure that fopen() failed for the right reason. */
-       if (errno != ENOENT) {
-           perror("Disk error with first name");
-           return EXIT_FAILURE;
-       }
-
-       errno = 0;
-       file = fopen(name2, "r");
-       if (file != NULL) {
-           fclose(file);
-           continue;
-       }
-       if (errno != ENOENT) {
-           perror("Disk error with second name");
-           return EXIT_FAILURE;
-       }
-
-       break;                          /* neither one exists; do next step */
+        r = rand();
+        sprintf(name1, "r%04.4u.1", (unsigned)r);
+        sprintf(name2, "r%04.4u.2", (unsigned)r);
+
+        /* Ensure that neither file-name exists. */
+        errno = 0;
+        file = fopen(name1, "r");
+        if (file != NULL) {
+            fclose(file);
+            continue;                   /* try a different spelling */
+        }
+
+        /* Make sure that fopen() failed for the right reason. */
+        if (errno != ENOENT) {
+            perror("Disk error with first name");
+            return EXIT_FAILURE;
+        }
+
+        errno = 0;
+        file = fopen(name2, "r");
+        if (file != NULL) {
+            fclose(file);
+            continue;
+        }
+        if (errno != ENOENT) {
+            perror("Disk error with second name");
+            return EXIT_FAILURE;
+        }
+
+        break;                          /* neither one exists; do next step */
     }
 
     /* Create the first file.
@@ -58,16 +58,16 @@ int main(void)
     printf("Creating file: %s\n", name1);
     file = fopen(name1, "w");
     if (file == NULL) {
-       _poserror("Disk error making first file");
-       return EXIT_FAILURE;
+        _poserror("Disk error making first file");
+        return EXIT_FAILURE;
     }
     fclose(file);
 
     /* Verify that the file-name exists now. */
     file = fopen(name1, "r");
     if (file == NULL) {
-       _poserror("Cannot find first name");
-       return EXIT_FAILURE;
+        _poserror("Cannot find first name");
+        return EXIT_FAILURE;
     }
     fclose(file);
 
@@ -78,23 +78,23 @@ int main(void)
     printf("Renaming %s to %s\n", name1, name2);
     r = rename(name1, name2);
     if (r < 0) {
-       _poserror("rename() failed");
-       return EXIT_FAILURE;
+        _poserror("rename() failed");
+        return EXIT_FAILURE;
     }
 
     /* Verify that the first file-name no longer exists. */
     file = fopen(name1, "r");
     if (file != NULL) {
-       fclose(file);
-       _poserror("First name still exists");
-       return EXIT_FAILURE;
+        fclose(file);
+        _poserror("First name still exists");
+        return EXIT_FAILURE;
     }
 
     /* Verify that the second file-name exists now. */
     file = fopen(name2, "r");
     if (file == NULL) {
-       _poserror("Cannot find second name");
-       return EXIT_FAILURE;
+        _poserror("Cannot find second name");
+        return EXIT_FAILURE;
     }
     fclose(file);
 
@@ -104,8 +104,8 @@ int main(void)
     printf("Removing %s\n", name2);
     r = remove(name2);
     if (r < 0) {
-       _poserror("remove() failed");
-       return EXIT_FAILURE;
+        _poserror("remove() failed");
+        return EXIT_FAILURE;
     }
 
     printf("rename() passed the test.\n");