[hackers] [sent] Correctly handle files that contain no slides || Laslo Hunhold

From: <git_AT_suckless.org>
Date: Thu, 7 Sep 2017 23:40:29 +0200 (CEST)

commit a5f760fa0ed3e6e8a04675d7cfa97cdb75791efd
Author: Laslo Hunhold <dev_AT_frign.de>
AuthorDate: Thu Sep 7 11:01:10 2017 +0200
Commit: Markus Teich <teichm_AT_fs.tum.de>
CommitDate: Thu Sep 7 23:37:00 2017 +0200

    Correctly handle files that contain no slides
    
    Otherwise, on reloading sent would segfault. Move the check-logic to
    load() rather than doing it in main() to prevent other misuses of it in
    the future.

diff --git a/sent.c b/sent.c
index 0da2bff..c50a572 100644
--- a/sent.c
+++ b/sent.c
_AT_@ -457,6 +457,9 @@ load(FILE *fp)
                 if (!p)
                         break;
         }
+
+ if (!slidecount)
+ die("sent: No slides in file");
 }
 
 void
_AT_@ -695,9 +698,6 @@ main(int argc, char *argv[])
         load(fp);
         fclose(fp);
 
- if (!slidecount)
- usage();
-
         xinit();
         run();
 
Received on Thu Sep 07 2017 - 23:40:29 CEST

This archive was generated by hypermail 2.3.0 : Thu Sep 07 2017 - 23:48:20 CEST