From f072bf2637f77595a7e49fca4deb6cf76d44ae3d Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Tue, 28 Feb 2023 14:59:48 -0500 Subject: fix extra newline for empty directories --- ls.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ls.c b/ls.c index 03aec00..277811c 100644 --- a/ls.c +++ b/ls.c @@ -1,7 +1,7 @@ /* * UNG's Not GNU * - * Copyright (c) 2011-2022, Jakob Kaivo + * Copyright (c) 2011-2023, Jakob Kaivo * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -450,6 +450,10 @@ static void ls_print_single(size_t n, struct file_info files[static n]) static void ls_print_columns(size_t n, struct file_info files[static n]) { + if (n == 0) { + return; + } + size_t widest = ls_find_widest(n, files); size_t columns = ls_get_columns(); if (widest > columns / 2) { -- cgit v1.2.1