]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
* src/tac.c (tac_file): Remove temporary prototype and move this
authorJim Meyering <jim@meyering.net>
Fri, 29 Oct 2004 21:59:33 +0000 (21:59 +0000)
committerJim Meyering <jim@meyering.net>
Fri, 29 Oct 2004 21:59:33 +0000 (21:59 +0000)
function `down' so that it precedes definition of tac_nonseekable.

src/tac.c

index ca172d29196dc771a4c9307c9bc97b420517898e..4c73a74229434748a2dc2020ae9d8791d9e58943 100644 (file)
--- a/src/tac.c
+++ b/src/tac.c
@@ -372,60 +372,6 @@ tac_seekable (int input_fd, const char *file)
     }
 }
 
-/* Temporary prototype -- I'm about to reorder functions.  */
-static bool tac_nonseekable (int input_fd, const char *file);
-
-/* Print FILE in reverse, copying it to a temporary
-   file first if it is not seekable.
-   Return true if successful.  */
-
-static bool
-tac_file (const char *filename)
-{
-  bool ok;
-  off_t file_size;
-  int fd;
-
-  if (STREQ (filename, "-"))
-    {
-      have_read_stdin = true;
-      fd = STDIN_FILENO;
-      filename = _("standard input");
-    }
-  else
-    {
-      fd = open (filename, O_RDONLY);
-      if (fd < 0)
-       {
-         error (0, errno, _("cannot open %s for reading"), quote (filename));
-         return false;
-       }
-    }
-
-  /* We need binary I/O, since `tac' relies
-     on `lseek' and byte counts.
-
-     Binary output will leave the lines' ends (NL or
-     CR/LF) intact when the output is a disk file.
-     Writing a file with CR/LF pairs at end of lines in
-     text mode has no visible effect on console output,
-     since two CRs in a row are just like one CR.  */
-  SET_BINARY2 (fd, STDOUT_FILENO);
-
-  file_size = lseek (fd, (off_t) 0, SEEK_END);
-
-  ok = (0 <= file_size
-       ? tac_seekable (fd, filename)
-       : tac_nonseekable (fd, filename));
-
-  if (fd != STDIN_FILENO && close (fd) == -1)
-    {
-      error (0, errno, _("closing %s"), quote (filename));
-      ok = false;
-    }
-  return ok;
-}
-
 #if DONT_UNLINK_WHILE_OPEN
 
 static const char *file_to_remove;
@@ -520,6 +466,57 @@ tac_nonseekable (int input_fd, const char *file)
   return tac_seekable (fileno (tmp_stream), tmp_file);
 }
 
+/* Print FILE in reverse, copying it to a temporary
+   file first if it is not seekable.
+   Return true if successful.  */
+
+static bool
+tac_file (const char *filename)
+{
+  bool ok;
+  off_t file_size;
+  int fd;
+
+  if (STREQ (filename, "-"))
+    {
+      have_read_stdin = true;
+      fd = STDIN_FILENO;
+      filename = _("standard input");
+    }
+  else
+    {
+      fd = open (filename, O_RDONLY);
+      if (fd < 0)
+       {
+         error (0, errno, _("cannot open %s for reading"), quote (filename));
+         return false;
+       }
+    }
+
+  /* We need binary I/O, since `tac' relies
+     on `lseek' and byte counts.
+
+     Binary output will leave the lines' ends (NL or
+     CR/LF) intact when the output is a disk file.
+     Writing a file with CR/LF pairs at end of lines in
+     text mode has no visible effect on console output,
+     since two CRs in a row are just like one CR.  */
+  SET_BINARY2 (fd, STDOUT_FILENO);
+
+  file_size = lseek (fd, (off_t) 0, SEEK_END);
+
+  ok = (0 <= file_size
+       ? tac_seekable (fd, filename)
+       : tac_nonseekable (fd, filename));
+
+  if (fd != STDIN_FILENO && close (fd) == -1)
+    {
+      error (0, errno, _("closing %s"), quote (filename));
+      ok = false;
+    }
+  return ok;
+}
+
 #if 0
 /* BUF_END points one byte past the end of the buffer to be searched.  */