[hackers] [sbase] tail: Fix operation with +n argument || Michael Forney

From: <git_AT_suckless.org>
Date: Mon, 2 Nov 2015 22:09:43 +0100 (CET)

commit 7604f990034fc9bf9f88d62471d05934d5a3765c
Author: Michael Forney <mforney_AT_mforney.org>
AuthorDate: Sun Nov 1 14:05:05 2015 -0800
Commit: sin <sin_AT_2f30.org>
CommitDate: Mon Nov 2 21:09:36 2015 +0000

    tail: Fix operation with +n argument
    
    POSIX says
    
      Copying shall begin at the point in the file indicated by the -c
      number or -n number options.
    
      The origin for counting shall be 1; that is, -c +1 represents the
      first byte of the file, -c -1 the last.
    
      The origin for counting shall be 1; that is, -n +1 represents the
      first line of the file, -n -1 the last.

diff --git a/tail.c b/tail.c
index 09f5b58..4ab5fde 100644
--- a/tail.c
+++ b/tail.c
_AT_@ -18,7 +18,7 @@ dropinit(FILE *fp, const char *str, size_t n)
 {
         Rune r;
         char *buf = NULL;
- size_t size = 0, i = 0;
+ size_t size = 0, i = 1;
         ssize_t len;
 
         if (mode == 'n') {
Received on Mon Nov 02 2015 - 22:09:43 CET

This archive was generated by hypermail 2.3.0 : Mon Nov 02 2015 - 22:12:11 CET