sbase

suckless unix tools
git clone git://git.2f30.org/sbase.git
Log | Files | Refs | README | LICENSE

commit 9f8deb4b23e9ec4957692295b06060cc7cf85bf9
parent 43c4213631b36bbf21f60841b3d3b592f911648b
Author: David Galos <galosd83@students.rowan.edu>
Date:   Sat Jul 20 01:27:42 -0400

Tar compiles on BSD, thanks Roberto E. Vargas Caballero. Also remove tons of trailing whitespace.

Diffstat:
LICENSE | 4++--
chgrp.1 | 6+++---
chroot.1 | 6+++---
chroot.c | 8++++----
chvt.1 | 2+-
cp.c | 4++--
env.1 | 12++++++------
env.c | 2+-
mknod.1 | 4++--
nice.1 | 6+++---
paste.1 | 16++++++++--------
printenv.1 | 6+++---
renice.1 | 2+-
rmdir.1 | 4++--
seq.1 | 6+++---
split.1 | 20++++++++++----------
split.c | 4++--
sync.1 | 8++++----
tar.1 | 10+++++-----
tar.c | 17+++++------------
unlink.1 | 2+-
wc.c | 4++--
who.1 | 2+-
who.c | 2+-
yes.1 | 6+++---
25 files changed, 78 insertions(+), 85 deletions(-)
diff --git a/LICENSE b/LICENSE @@ -9,8 +9,8 @@ MIT/X Consortium License © 2011 Random832 <random832@fastmail.us> © 2012 William Haddon <william@haddonthethird.net> © 2012 Kurt H. Maier <khm@intma.in> -© 2012 Christoph Lohmann <20h@r-36.net> -© 2012 David Galos <galosd83@students.rowan.edu> +© 2012 Christoph Lohmann <20h@r-36.net> +© 2012 David Galos <galosd83@students.rowan.edu> © 2012 Robert Ransom <rransom.8774@gmail.com> © 2013 Jakob Kramer <jakob.kramer@gmx.de> diff --git a/chgrp.1 b/chgrp.1 @@ -8,13 +8,13 @@ chgrp \- change the file group ownership .I file... .SH DESCRIPTION .B chgrp -sets the group id of the files specified by +sets the group id of the files specified by .IR file to the gid of the group named .IR group. -If the +If the .IR R -flag is specified, this process is recursively applied to +flag is specified, this process is recursively applied to everything in .IR file. diff --git a/chroot.1 b/chroot.1 @@ -9,15 +9,15 @@ chroot \- invoke a command with a different root directory .SH DESCRIPTION .B chroot -runs +runs .IR command -after changing the root directory to +after changing the root directory to .IR dir with the .B chroot system call, and changing the working directory to the new root. -If +If .IR command is not specified, an interactive shell is started in the new root. diff --git a/chroot.c b/chroot.c @@ -8,16 +8,16 @@ int main(int argc, char **argv) { char *shell[] = {"/bin/sh", "-i", NULL}; - + if(getenv("SHELL")) shell[0] = getenv("SHELL"); if(argc < 2) usage(); - + if(chroot(argv[1]) == -1) eprintf("chroot: '%s':", argv[1]); - + if(chdir("/") == -1) eprintf("chroot:"); @@ -26,7 +26,7 @@ main(int argc, char **argv) } else { execvp(argv[2], argv+2); } - + eprintf("chroot: '%s':", argv[2]); return 1; } diff --git a/chvt.1 b/chvt.1 @@ -6,6 +6,6 @@ chvt \- change foreground virtual terminal .I N .SH DESCRIPTION .B chvt -brings /dev/ttyN to the foreground. This has the +brings /dev/ttyN to the foreground. This has the same effect as Ctrl-Alt-FN. diff --git a/cp.c b/cp.c @@ -9,7 +9,7 @@ int main(int argc, char *argv[]) { struct stat st; - + ARGBEGIN { case 'r': cp_rflag = true; @@ -17,7 +17,7 @@ main(int argc, char *argv[]) default: exit(EXIT_FAILURE); } ARGEND; - + if(argc > 2 && !(stat(argv[argc-1], &st) == 0 && S_ISDIR(st.st_mode))) eprintf("%s: not a directory\n", argv[argc-1]); enmasse(argc, argv, cp); diff --git a/env.1 b/env.1 @@ -4,23 +4,23 @@ env \- modify the environment, then print it or run a command. .SH SYNOPSIS .B env .RB [ \-i ] -.RB [ \-u +.RB [ \-u .IR name ]... .RI [ name=value ]... -.RI [ cmd +.RI [ cmd .RI [ arg ...]] .SH DESCRIPTION .B env -removes part of the environment according to the flags, then adds or +removes part of the environment according to the flags, then adds or sets each variable specified by -.IR name +.IR name to equal .IR value . -If +If .IR cmd -is given, it is executed in this new environment; otherwise, the +is given, it is executed in this new environment; otherwise, the modified environment is printed to standard out. .SH OPTIONS diff --git a/env.c b/env.c @@ -33,7 +33,7 @@ main(int argc, char **argv) } while(environ && *environ) - printf("%s\n", *environ++); + printf("%s\n", *environ++); return 0; } diff --git a/mknod.1 b/mknod.1 @@ -21,7 +21,7 @@ and minor number .IR minor . .IR type -specifies what kind of special file will be created, +specifies what kind of special file will be created, and must be one of: .TP .BR u \ or\ c @@ -33,7 +33,7 @@ A block device. .SH OPTIONS .TP .B \-m "mode" -Set the mode of the new file based on the octal value of +Set the mode of the new file based on the octal value of .IR mode . .SH SEE ALSO diff --git a/nice.1 b/nice.1 @@ -10,9 +10,9 @@ nice \- invoke a utility with an altered nice value .B nice invokes .IR command -with a nice value equal to the current nice value plus -.IR inc, +with a nice value equal to the current nice value plus +.IR inc, which defaults to 10 if unspecified. .SH SEE ALSO -.IR renice (1) nice (2) +.IR renice (1) nice (2) diff --git a/paste.1 b/paste.1 @@ -22,7 +22,7 @@ of concatenates the corresponding lines of the input files. The newline of every line except the line from the last input file is replaced with a tab. -If an end-of-file condition is detected on one or more input files, +If an end-of-file condition is detected on one or more input files, but not all input files, .B paste behaves as though empty lines were read from the files on which @@ -35,17 +35,17 @@ option is specified. unless a backslash character appears in .I list each character is an element specifying a delimiter. -If a backslash character appears, that and one or more characters +If a backslash character appears, that and one or more characters following it are an element specifying a delimiter. -These elements specify one or more characters to use, -instead of the default tab, to replace the newline of the input +These elements specify one or more characters to use, +instead of the default tab, to replace the newline of the input lines. The elements in .I list -are used circularly; that is, when the +are used circularly; that is, when the .I list is exhausted the first element from the list is reused. When the -.B \-s +.B \-s option is specified, the last newline in a file is not be modified. The delimiter is reset to the first element of list after each file operand is processed. @@ -69,9 +69,9 @@ If Any other characters follow the backslash, results are unspecified. .RE .TP .B \-s -concatenate all of the lines of each separate input file in command line +concatenate all of the lines of each separate input file in command line order. The newline of every line except the last line in each input file -are replaced with the tab, unless otherwise specified by the +are replaced with the tab, unless otherwise specified by the .B \-d option. .PP diff --git a/printenv.1 b/printenv.1 @@ -7,12 +7,12 @@ printenv \- print out the environment or the values of specific variables. .SH DESCRIPTION .B printenv prints the entire environment as key=values pairs when -no +no .IR var -is specified. Otherwise, in the order specified, +is specified. Otherwise, in the order specified, .B printenv prints the value only of each -.IR var, +.IR var, one per line. .SH SEE ALSO diff --git a/renice.1 b/renice.1 @@ -20,7 +20,7 @@ The utility requests that the nice values of one or more running processes be changed. By default, the applicable processes are specified by their process IDs. When a process group is specified -(see +(see .B -g ), the request applies to all processes in the process group. If the requested increment would raise or lower the nice value of the diff --git a/rmdir.1 b/rmdir.1 @@ -18,8 +18,8 @@ will be successful, but .nf rmdir foo foo/bar .fi -will only succeed in removing +will only succeed in removing .BR foo/bar. .SH SEE ALSO -.IR rm (1) rmdir (2) unlink (1) unlink (2) +.IR rm (1) rmdir (2) unlink (1) unlink (2) diff --git a/seq.1 b/seq.1 @@ -2,7 +2,7 @@ .SH NAME seq \- print a sequence of numbers .SH SYNOPSIS -.B seq +.B seq .RB [ \-w ] .RB [ \-f .IR fmt ] @@ -12,8 +12,8 @@ seq \- print a sequence of numbers .RI [ step ]] .IR end .SH DESCRIPTION -.B seq -will print a sequence of numbers from +.B seq +will print a sequence of numbers from .I start (default 1) to .IR end , diff --git a/split.1 b/split.1 @@ -4,18 +4,18 @@ split \- split up a file .SH SYNOPSIS .B split .RB [ \-d ] -.RB [ \-a +.RB [ \-a .IR len ] -.RB [ \-b +.RB [ \-b .RI [ bytes [k|m|g]]] -.RB [ \-l +.RB [ \-l .RI [ lines ]] -.RI [ input +.RI [ input .RI [ prefix ]] .SH DESCRIPTION .B split -Reads a file, splitting it into smaller files, every +Reads a file, splitting it into smaller files, every .IR bytes bytes or @@ -23,9 +23,9 @@ or lines. If .B split runs out of filenames before all the data can be written, it stops at the -last valid filename, leaving all the written data on the disk. +last valid filename, leaving all the written data on the disk. -The +The .IR b and .IR l @@ -38,19 +38,19 @@ Use decimal suffixes rather than alphabetical. .TP .B \-a "len" -Set the suffix length to +Set the suffix length to .IR len characters long. .TP .B \-b [bytes[k|m|g]] -Start a new file every +Start a new file every .IR bytes bytes. The units k, m, and g are case insensitive, and powers of 2, not 10. .TP .B \-l [lines] -Start a new file every +Start a new file every .IR lines lines. diff --git a/split.c b/split.c @@ -12,7 +12,7 @@ static void usage(void); static int base = 26, start = 'a'; -int +int main(int argc, char **argv) { int plen, slen = 2; @@ -36,7 +36,7 @@ main(int argc, char **argv) tmp = ARGF(); if(tmp == NULL) break; - + size = strtoull(tmp, &end, 10); if(*end == '\0') break; diff --git a/sync.1 b/sync.1 @@ -1,13 +1,13 @@ .TH SYNC 1 sbase\-VERSION .SH NAME -sync \- flush disk cache +sync \- flush disk cache .SH SYNOPSIS .B sync .SH DESCRIPTION .B sync -invokes -.IR sync(2) -to flush all unwritten changes to the disk. This is +invokes +.IR sync(2) +to flush all unwritten changes to the disk. This is usually done before shutting down, rebooting or halting. .SH SEE ALSO diff --git a/tar.1 b/tar.1 @@ -27,11 +27,11 @@ tar \- create, list or extract a tape archive .B tar .RB [ \-C .IR dir ] -.B x|tf +.B x|tf .I tarfile .SH DESCRIPTION -.B tar +.B tar is the standard file archiver. Generally the archives created with it are further compressed. .SH OPTIONS @@ -42,9 +42,9 @@ extract tarball from stdin .B t list all files in tarball from stdin .TP -.BI c\ path -creates tarball from -.I path +.BI c\ path +creates tarball from +.I path and prints it to stdout .TP .BI f\ tarfile diff --git a/tar.c b/tar.c @@ -40,7 +40,6 @@ enum Type { }; static void putoctal(char *, unsigned, int); -static int strlcpy(char *, const char *, int n); static int archive(const char *, const struct stat *, int); static int unarchive(char *, int, char[Blksiz]); static int print(char *, int , char[Blksiz]); @@ -143,12 +142,6 @@ putoctal(char *dst, unsigned num, int n) } int -strlcpy(char *dst, const char *src, int n) -{ - return snprintf(dst, n, "%s", src); -} - -int archive(const char* path, const struct stat* sta, int type) { unsigned char b[Blksiz]; @@ -166,7 +159,7 @@ archive(const char* path, const struct stat* sta, int type) gr = getgrgid(st.st_gid); memset(b, 0, sizeof b); - strlcpy (h->name, path, sizeof h->name); + snprintf(h->name, sizeof h->name, "%s", path); putoctal(h->mode, (unsigned)st.st_mode&0777, sizeof h->mode); putoctal(h->uid, (unsigned)st.st_uid, sizeof h->uid); putoctal(h->gid, (unsigned)st.st_gid, sizeof h->gid); @@ -174,8 +167,8 @@ archive(const char* path, const struct stat* sta, int type) putoctal(h->mtime, (unsigned)st.st_mtime, sizeof h->mtime); memcpy(h->magic, "ustar", sizeof h->magic); memcpy(h->version, "00", sizeof h->version); - strlcpy(h->uname, pw->pw_name, sizeof h->uname); - strlcpy(h->gname, gr->gr_name, sizeof h->gname); + snprintf(h->uname, sizeof h->uname, "%s", pw->pw_name); + snprintf(h->gname, sizeof h->gname, "%s", gr->gr_name); mode = st.st_mode; if(S_ISREG(mode)) { @@ -229,7 +222,7 @@ unarchive(char *fname, int l, char b[Blksiz]) break; case HARDLINK: case SYMLINK: - strlcpy(lname, h->link, sizeof lname); + snprintf(lname, sizeof lname, "%s", h->link); if(!((h->type == HARDLINK) ? link : symlink)(lname, fname)) perror(fname); break; @@ -291,7 +284,7 @@ xt(int (*fn)(char*, int, char[Blksiz])) Header *h = (void*)b; while(fread(b, Blksiz, 1, tarfile) && h->name[0] != '\0') { - strlcpy(fname, h->name, sizeof fname); + snprintf(fname, sizeof fname, "%s", h->name); fn(fname, strtol(h->size, 0, 8), b); } } diff --git a/unlink.1 b/unlink.1 @@ -6,7 +6,7 @@ unlink \- call the unlink function .RB file .SH DESCRIPTION .B unlink -calls the +calls the .IR unlink function on .IR file. diff --git a/wc.c b/wc.c @@ -19,7 +19,7 @@ main(int argc, char *argv[]) { FILE *fp; int i; - + ARGBEGIN { case 'c': cmode = 'c'; @@ -36,7 +36,7 @@ main(int argc, char *argv[]) default: eprintf("usage: %s [-clmw] [files...]\n", argv0); } ARGEND; - + if (argc == 0) { wc(stdin, NULL); } else { diff --git a/who.1 b/who.1 @@ -6,7 +6,7 @@ who \- print who has logged on .SH DESCRIPTION .B who -prints a list of who has logged on, their controlling tty, and the +prints a list of who has logged on, their controlling tty, and the time at which they logged on. .SH BUGS diff --git a/who.c b/who.c @@ -33,7 +33,7 @@ main(int argc, char **argv) return 0; } -void +void usage(void) { eprintf("usage: who\n"); diff --git a/yes.1 b/yes.1 @@ -1,10 +1,10 @@ .TH YES 1 sbase\-VERSION .SH NAME -yes \- output a string repeatedly +yes \- output a string repeatedly .SH SYNOPSIS -.B yes +.B yes .RB [ string ... ] .SH DESCRIPTION -.B yes +.B yes will repeatedly output 'y' or the strings specified.