From aa1526183b2479c1bf3d29ddbd5bafcd13443254 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 19 Feb 2018 19:03:59 +0100 Subject: Add readme and loc.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 31 +++++++++++++++++++++++++++++++ README | 26 ++++++++++++++++++++++++++ config.mk | 6 ++++++ loc.1 | 42 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+) create mode 100644 Makefile create mode 100644 README create mode 100644 config.mk create mode 100644 loc.1 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..00e76ec --- /dev/null +++ b/Makefile @@ -0,0 +1,31 @@ +.POSIX: + +CONFIGFILE = config.mk +include $(CONFIGFILE) + +all: loc +loc.o: loc.c arg.h + +loc: loc.o + $(CC) -o $@ loc.o $(LDFLAGS) + +check: + true + +install: loc + mkdir -p -- "$(DESTDIR)$(PREFIX)/bin/" + mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man1/" + cp -- loc "$(DESTDIR)$(PREFIX)/bin/loc" + cp -- loc.1 "$(DESTDIR)$(MANPREFIX)/man1/loc.1" + +uninstall: + -rm -f -- "$(DESTDIR)$(PREFIX)/bin/loc" + -rm -f -- "$(DESTDIR)$(MANPREFIX)/man1/loc.1" + +clean: + -rm -f -- loc.o loc + +.SUFFIXES: +.SUFFIXES: .o .c + +.PHONY: all check install uninstall clean diff --git a/README b/README new file mode 100644 index 0000000..24bc05c --- /dev/null +++ b/README @@ -0,0 +1,26 @@ +NAME + loc - count number of lines of code + +SYNOPSIS + loc [file] ... + +DESCRIPTION + loc counts the number of lines of code for each specified + file. loc will treat each file as a C source code or C header + file. If file is -, the standard input is read. + + If no file is specified, the standard input is read, and + the number of lines of code is output on the format + + "%zu\n", <#lines of code> + + If exactly one file is specified, its number of lines of + code is output on the format + + "%zu\n", <#lines of code> + + If more than one file is specified, each successfully + line counted file will have its of lines of code output on + the format + + "%s:%*s%zu\n", , , "", <#lines of code> diff --git a/config.mk b/config.mk new file mode 100644 index 0000000..dc5b11a --- /dev/null +++ b/config.mk @@ -0,0 +1,6 @@ +PREFIX = /usr +MAXPREFIX = $(PREFIX)/share/man + +CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 +CFLAGS = -std=c99 -Wall -Wextra -pedantic $(CPPFLAGS) +LDFLAGS = diff --git a/loc.1 b/loc.1 new file mode 100644 index 0000000..8c87eeb --- /dev/null +++ b/loc.1 @@ -0,0 +1,42 @@ +.TH LOC 1 "loc" +.SH NAME +loc - count number of lines of code +.SH SYNOPSIS +.B loc +.RI [ file "] ..." +.SH DESCRIPTION +.B loc +counts the number of lines of code for each specified +.BR file . +.B loc +will treat each file as a C source code or C header file. If +.I file +is +.BR - , +the standard input is read. +.PP +If no +.I file +is specified, the standard input is read, and the number +of lines of code is output on the format +.nf + + \fB"%zu\n"\fP, <\fI#lines of code\fP> +.fi +.PP +If exactly one +.I file +is specified, its number of lines of code is output on the format +.nf + + \fB"%zu\n"\fP, <\fI#lines of code\fP> +.fi +.PP +If more than one +.I file +is specified, each successfully line counted file will have +its of lines of code output on the format +.nf + + \fB"%s:%*s%zu\n"\fP, <\fIfile\fP>, <\fIsome positive integer\fP>, \fB""\fP, <\fI#lines of code\fP> +.fi -- cgit v1.2.3-70-g09d2