Remove trailing whitespace. Update copyright to include 2004.

This commit is contained in:
Eric Andersen
2004-03-15 08:29:22 +00:00
parent 8854004b41
commit c7bda1ce65
374 changed files with 2048 additions and 2051 deletions

View File

@@ -10,7 +10,7 @@ config CONFIG_BASENAME
default n
help
basename is used to strip the directory and suffix from filenames,
leaving just the filename itself. Enable this option if you wish
leaving just the filename itself. Enable this option if you wish
to enable the 'basename' utility.
config CONFIG_CAL
@@ -101,7 +101,7 @@ config CONFIG_DD
help
dd copies a file (from standard input to standard output,
by default) using specific input and output blocksizes,
while optionally performing conversions on it.
while optionally performing conversions on it.
config CONFIG_DF
bool "df"
@@ -154,7 +154,7 @@ config CONFIG_FEATURE_FANCY_ECHO
default y
depends on CONFIG_ECHO
help
This adds options (-n and -e) to echo.
This adds options (-n and -e) to echo.
config CONFIG_ENV
bool "env"

View File

@@ -1,6 +1,6 @@
# Makefile for busybox
#
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
# Makefile for busybox
#
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -2,7 +2,7 @@
/*
* Mini basename implementation for busybox
*
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -161,7 +161,7 @@ int cal_main(int argc, char **argv)
int row, len, days[MAXDAYS];
int *dp = days;
char lineout[30];
day_array(month, year, dp);
len = sprintf(lineout, "%s %d", month_names[month - 1], year);
bb_printf("%*s%s\n%s\n",
@@ -176,7 +176,7 @@ int cal_main(int argc, char **argv)
int row, which_cal, week_len, days[12][MAXDAYS];
int *dp;
char lineout[80];
sprintf(lineout, "%d", year);
center(lineout,
(WEEK_LEN * 3 + HEAD_SEP * 2)
@@ -317,7 +317,7 @@ static void blank_string(char *buf, size_t buflen)
static char *build_row(char *p, int *dp)
{
int col, val, day;
memset(p, ' ', (julian + DAY_LEN) * 7);
col = 0;

View File

@@ -2,7 +2,7 @@
/*
* Mini chgrp implementation for busybox
*
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -63,7 +63,7 @@ int chgrp_main(int argc, char **argv)
/* Ok, ready to do the deed now */
do {
if (! recursive_action (*argv, recursiveFlag, FALSE, FALSE,
if (! recursive_action (*argv, recursiveFlag, FALSE, FALSE,
fileAction, fileAction, &gid)) {
retval = EXIT_FAILURE;
}

View File

@@ -2,7 +2,7 @@
/*
* Mini chmod implementation for busybox
*
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* Reworked by (C) 2002 Vladimir Oleynik <dzo@simtreas.ru>
* to correctly parse '-rwxgoa'

View File

@@ -2,7 +2,7 @@
/*
* Mini chown implementation for busybox
*
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -84,10 +84,10 @@ int chown_main(int argc, char **argv)
uid = get_ug_id(*argv, my_getpwnam);
++argv;
/* Ok, ready to do the deed now */
do {
if (! recursive_action (*argv, (flags & FLAG_R), FALSE, FALSE,
if (! recursive_action (*argv, (flags & FLAG_R), FALSE, FALSE,
fileAction, fileAction, NULL)) {
retval = EXIT_FAILURE;
}

View File

@@ -2,7 +2,7 @@
/*
* Mini chroot implementation for busybox
*
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -3,7 +3,7 @@
* cut.c - minimalist version of cut
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Mark Whitley <markw@lineo.com>, <markw@codepoet.org>
* Written by Mark Whitley <markw@codepoet.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -69,7 +69,7 @@ static int cmpfunc(const void *a, const void *b)
/*
* parse_lists() - parses a list and puts values into startpos and endpos.
* valid list formats: N, N-, N-M, -M
* valid list formats: N, N-, N-M, -M
* more than one list can be seperated by commas
*/
static void parse_lists(char *lists)
@@ -96,7 +96,7 @@ static void parse_lists(char *lists)
s = strtoul(ntok, &junk, 10);
if(*junk != '\0' || s < 0)
bb_error_msg_and_die("invalid byte or field list");
/* account for the fact that arrays are zero based, while the user
* expects the first char on the line to be char # 1 */
if (s != 0)
@@ -125,7 +125,7 @@ static void parse_lists(char *lists)
/* if there's something left to tokenize, the user past an invalid list */
if (ltok)
bb_error_msg_and_die("invalid byte or field list");
/* add the new list */
cut_lists = xrealloc(cut_lists, sizeof(struct cut_list) * (++nlists));
cut_lists[nlists-1].startpos = s;
@@ -227,7 +227,7 @@ static void cut_file_by_lines(const char *line, unsigned int linenum)
{
static int c = 0;
static int l = -1;
/* I can't initialize this above cuz the "initializer isn't
* constant" *sigh* */
if (l == -1)

View File

@@ -3,7 +3,7 @@
* Mini date implementation for busybox
*
* by Matthew Grant <grantma@anathoth.gen.nz>
*
*
* iso-format handling added by Robert Griebl <griebl@gmx.de>
*
* This program is free software; you can redistribute it and/or modify
@@ -33,7 +33,7 @@
#include "busybox.h"
/* This 'date' command supports only 2 time setting formats,
/* This 'date' command supports only 2 time setting formats,
all the GNU strftime stuff (its in libc, lets use it),
setting time using UTC and displaying int, as well as
an RFC 822 complient date output for shell scripting

View File

@@ -2,7 +2,7 @@
/*
* Mini df implementation for busybox
*
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
* based on original code by (I think) Bruce Perens <bruce@pixar.com>.
*
* This program is free software; you can redistribute it and/or modify
@@ -51,7 +51,7 @@ extern int df_main(int argc, char **argv)
long blocks_used;
long blocks_percent_used;
#ifdef CONFIG_FEATURE_HUMAN_READABLE
unsigned long df_disp_hr = KILOBYTE;
unsigned long df_disp_hr = KILOBYTE;
#endif
int status = EXIT_SUCCESS;
unsigned long opt;
@@ -115,7 +115,7 @@ extern int df_main(int argc, char **argv)
bb_perror_msg("%s", mount_point);
goto SET_ERROR;
}
if ((s.f_blocks > 0) || !mount_table){
blocks_used = s.f_blocks - s.f_bfree;
blocks_percent_used = 0;
@@ -124,7 +124,7 @@ extern int df_main(int argc, char **argv)
+ (blocks_used + s.f_bavail)/2
) / (blocks_used + s.f_bavail);
}
if (strcmp(device, "rootfs") == 0) {
continue;
} else if (strcmp(device, "/dev/root") == 0) {
@@ -134,15 +134,15 @@ extern int df_main(int argc, char **argv)
goto SET_ERROR;
}
}
#ifdef CONFIG_FEATURE_HUMAN_READABLE
bb_printf("%-21s%9s ", device,
make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr));
bb_printf("%9s ",
make_human_readable_str( (s.f_blocks - s.f_bfree),
s.f_bsize, df_disp_hr));
bb_printf("%9s %3ld%% %s\n",
make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr),
blocks_percent_used, mount_point);

View File

@@ -2,7 +2,7 @@
/*
* Mini dirname implementation for busybox
*
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -50,7 +50,7 @@ typedef unsigned long int bb_uint64_t;
static const char letters[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
// if fn is NULL then input is stdin and output is stdout
static int convert(char *fn, int ConvType)
static int convert(char *fn, int ConvType)
{
int c, fd;
struct timeval tv;
@@ -156,12 +156,12 @@ static int convert(char *fn, int ConvType)
return 0;
}
int dos2unix_main(int argc, char *argv[])
int dos2unix_main(int argc, char *argv[])
{
int ConvType = CT_AUTO;
int o;
//See if we are supposed to be doing dos2unix or unix2dos
//See if we are supposed to be doing dos2unix or unix2dos
if (argv[0][0]=='d') {
ConvType = CT_DOS2UNIX;
}

View File

@@ -181,7 +181,7 @@ int du_main(int argc, char **argv)
#else
disp_k = 0;
#endif
}
}
#endif
/* Note: SUSv3 specifies that -a and -s options can not be used together

View File

@@ -55,7 +55,7 @@ extern int echo_main(int argc, char** argv)
* that all of the options specified are actually valid.
* Otherwise, the string should just be echoed.
*/
if (!*(p = *argv + 1)) { /* A single '-', so echo it. */
goto just_echo;
}
@@ -87,7 +87,7 @@ just_echo:
while ((c = *(*argv)++)) {
if (c == eflag) { /* Check for escape seq. */
if (**argv == 'c') {
/* '\c' means cancel newline and
/* '\c' means cancel newline and
* ignore all subsequent chars. */
goto DONE;
}
@@ -141,8 +141,8 @@ DONE:
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
* 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
*
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors

View File

@@ -5,7 +5,7 @@
* based on GNU expr Mike Parker.
* Copyright (C) 86, 1991-1997, 1999 Free Software Foundation, Inc.
*
* Busybox modifications
* Busybox modifications
* Copyright (c) 2000 Edward Betts <edward@debian.org>.
* Aug 2003 Vladimir Oleynik - reduced 464 bytes.
*

View File

@@ -2,7 +2,7 @@
/*
* Mini false implementation for busybox
*
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -47,7 +47,7 @@ extern int id_main(int argc, char **argv)
#ifdef CONFIG_SELINUX
int is_flask_enabled_flag = is_flask_enabled();
#endif
flags = bb_getopt_ulflags(argc, argv, "ugrn");
if (((flags & (JUST_USER | JUST_GROUP)) == (JUST_USER | JUST_GROUP))

View File

@@ -48,7 +48,7 @@ static const struct option install_long_options[] = {
{ "owner", 0, NULL, 'o' },
{ 0, 0, 0, 0 }
};
extern int install_main(int argc, char **argv)
{
struct stat statbuf;
@@ -116,7 +116,7 @@ extern int install_main(int argc, char **argv)
}
return(ret);
}
cp_mv_stat2(argv[argc - 1], &statbuf, lstat);
for (i = optind; i < argc - 1; i++) {
unsigned char *dest;
@@ -137,15 +137,15 @@ extern int install_main(int argc, char **argv)
/* Set the user and group id */
if (lchown(dest, uid, gid) == -1) {
bb_perror_msg("cannot change ownership of %s", dest);
ret = EXIT_FAILURE;
ret = EXIT_FAILURE;
}
if (flags & INSTALL_OPT_STRIP) {
if (execlp("strip", "strip", dest, NULL) == -1) {
bb_error_msg("strip failed");
ret = EXIT_FAILURE;
ret = EXIT_FAILURE;
}
}
}
return(ret);
}

View File

@@ -1,6 +1,6 @@
# Makefile for busybox
#
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -1,6 +1,6 @@
# Makefile for busybox
#
# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by

View File

@@ -2,7 +2,7 @@
/*
* Mini ln implementation for busybox
*
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -88,14 +88,14 @@ extern int ln_main(int argc, char **argv)
if (flag & LN_SYMLINK) {
link_func = symlink;
}
if (link_func(*argv, src) != 0) {
bb_perror_msg(src);
status = EXIT_FAILURE;
}
free(src_name);
} while ((++argv)[1]);
return status;

View File

@@ -315,7 +315,7 @@ static int count_dirs(struct dnode **dn, int nfiles, int notsubdirs)
if (S_ISDIR(dn[i]->dstat.st_mode)
&& (notsubdirs
|| ((dn[i]->name[0] != '.')
|| (dn[i]->name[1]
|| (dn[i]->name[1]
&& ((dn[i]->name[1] != '.')
|| dn[i]->name[2])))))
dirs++;
@@ -1055,7 +1055,7 @@ extern int ls_main(int argc, char **argv)
if ((all_fmt & STYLE_MASK) == STYLE_LONG && (all_fmt & LIST_ID_NUMERIC))
all_fmt &= ~LIST_ID_NAME; /* don't list names if numeric uid */
#endif
/* choose a display format */
if ((all_fmt & STYLE_MASK) == STYLE_AUTO)
#if STYLE_AUTO != 0

View File

@@ -1,7 +1,7 @@
/*
* Copyright (C) 2003 Glenn L. McGrath
* Copyright (C) 2003 Erik Andersen
*
* Copyright (C) 2003-2004 Erik Andersen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or

View File

@@ -50,7 +50,7 @@ extern int mknod_main(int argc, char **argv)
dev = (bb_xgetularg10_bnd(argv[2], 0, 255) << 8)
+ bb_xgetularg10_bnd(argv[3], 0, 255);
}
if (argc == 2) {
name = *argv;
if (mknod(name, mode, dev) == 0) {

View File

@@ -75,7 +75,7 @@ extern int mv_main(int argc, char **argv)
goto DO_MOVE;
}
}
do {
dest = concat_path_file(last, bb_get_last_path_component(*argv));
@@ -84,7 +84,7 @@ extern int mv_main(int argc, char **argv)
}
DO_MOVE:
if (dest_exists && !(flags & OPT_FILEUTILS_FORCE) &&
((access(dest, W_OK) < 0 && isatty(0)) ||
(flags & OPT_FILEUTILS_INTERACTIVE))) {
@@ -119,7 +119,7 @@ DO_MOVE:
bb_perror_msg("cannot remove `%s'", dest);
goto RET_1;
}
}
}
if ((copy_file(*argv, dest,
FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS) >= 0) &&
(remove_file(*argv, FILEUTILS_RECUR | FILEUTILS_FORCE) >= 0)) {
@@ -132,7 +132,7 @@ RET_1:
RET_0:
if (dest != last) {
free((void *) dest);
}
}
} while (*++argv != last);
return (status);

View File

@@ -106,7 +106,7 @@ static int print_esc __P((char *escstart));
static int print_formatted __P((char *format, int argc, char **argv));
static long xstrtol __P((char *s));
static unsigned long xstrtoul __P((char *s));
static void print_direc __P( (char *start, size_t length,
static void print_direc __P( (char *start, size_t length,
int field_width, int precision, char *argument));
static void print_esc_char __P((int c));
static void print_esc_string __P((char *str));
@@ -214,7 +214,7 @@ static int print_formatted(char *format, int argc, char **argv)
++f;
++direc_length;
}
/*
/*
if (!strchr ("diouxXfeEgGcs", *f))
fprintf(stderr, "%%%c: invalid directive", *f);
*/

View File

@@ -66,7 +66,7 @@ extern int rmdir_main(int argc, char **argv)
}
break;
} while (1);
} while (*++argv);
return status;

View File

@@ -118,7 +118,7 @@ int tail_main(int argc, char **argv)
/* Allow legacy syntax of an initial numeric option without -n. */
if (argc >=2 && ((argv[1][0] == '+') || ((argv[1][0] == '-')
/* && (isdigit)(argv[1][1]) */
&& (((unsigned int)(argv[1][1] - '0')) <= 9))))
&& (((unsigned int)(argv[1][1] - '0')) <= 9))))
{
optind = 2;
optarg = argv[1];

View File

@@ -97,7 +97,7 @@ int tee_main(int argc, char **argv)
}
#endif
/* Now we need to check for i/o errors on stdin and the various
/* Now we need to check for i/o errors on stdin and the various
* output files. Since we know that the first entry in the output
* file table is stdout, we can save one "if ferror" test by
* setting the first entry to stdin and checking stdout error

View File

@@ -2,7 +2,7 @@
/*
* test implementation for busybox
*
* Copyright (c) by a whole pile of folks:
* Copyright (c) by a whole pile of folks:
*
* test(1); version 7-like -- author Erik Baalbergen
* modified by Eric Gisin to be used as built-in.
@@ -10,7 +10,7 @@
* (-x -c -b -p -u -g -k) plus Korn's -L -nt -ot -ef and new -S (socket).
* modified by J.T. Conklin for NetBSD.
* modified by Herbert Xu to be used as built-in in ash.
* modified by Erik Andersen <andersen@codepoet.org> to be used
* modified by Erik Andersen <andersen@codepoet.org> to be used
* in busybox.
*
* This program is free software; you can redistribute it and/or modify

View File

@@ -2,7 +2,7 @@
/*
* Mini touch implementation for busybox
*
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -4,7 +4,7 @@
*
* Copyright (c) Michiel Huisjes
*
* This version of tr is adapted from Minix tr and was modified
* This version of tr is adapted from Minix tr and was modified
* by Erik Andersen <andersen@codepoet.org> to be used in busybox.
*
* This program is free software; you can redistribute it and/or modify
@@ -20,7 +20,7 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* Original copyright notice is retained at the end of this file.
*/
@@ -213,24 +213,24 @@ extern int tr_main(int argc, char **argv)
/*
* Copyright (c) 1987,1997, Prentice Hall
* All rights reserved.
*
*
* Redistribution and use of the MINIX operating system in source and
* binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
*
* Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
*
* Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
*
* Neither the name of Prentice Hall nor the names of the software
* authors or contributors may be used to endorse or promote
* products derived from this software without specific prior
* written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, AND
* CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF

View File

@@ -2,7 +2,7 @@
/*
* Mini true implementation for busybox
*
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -18,7 +18,7 @@
* Based on specification from
* http://www.opengroup.org/onlinepubs/007904975/utilities/uuencode.html
*
* Bugs: the spec doesnt mention anything about "`\n`\n" prior to the "end" line
* Bugs: the spec doesnt mention anything about "`\n`\n" prior to the "end" line
*/
@@ -50,7 +50,7 @@ static int read_stduu(FILE *src_stream, FILE *dst_stream)
if (length > 60) {
bb_error_msg_and_die("Line too long");
}
line_ptr++;
/* Tolerate an overly long line to acomadate a possible exta '`' */
if (strlen(line_ptr) < length) {

View File

@@ -26,7 +26,7 @@
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
*
* Rewritten to fix a number of problems and do some size optimizations.
* Problems in the previous busybox implementation (besides bloat) included:
* Problems in the previous busybox implementation (besides bloat) included:
* 1) broken 'wc -c' optimization (read note below)
* 2) broken handling of '-' args
* 3) no checking of ferror on EOF returns
@@ -110,33 +110,33 @@ int wc_main(int argc, char **argv)
char status = EXIT_SUCCESS;
char in_word;
char print_type;
print_type = bb_getopt_ulflags(argc, argv, wc_opts);
if (print_type == 0) {
print_type = (1 << WC_LINES) | (1 << WC_WORDS) | (1 << WC_CHARS);
}
argv += optind;
if (!*argv) {
*--argv = (char *) bb_msg_standard_input;
}
memset(totals, 0, sizeof(totals));
pcounts = counts;
do {
++num_files;
if (!(fp = bb_wfopen_input(*argv))) {
status = EXIT_FAILURE;
continue;
}
memset(counts, 0, sizeof(counts));
linepos = 0;
in_word = 0;
do {
++counts[WC_CHARS];
c = getc(fp);
@@ -177,21 +177,21 @@ int wc_main(int argc, char **argv)
} else {
continue;
}
counts[WC_WORDS] += in_word;
in_word = 0;
if (c == EOF) {
break;
}
} while (1);
if (totals[WC_LENGTH] < counts[WC_LENGTH]) {
totals[WC_LENGTH] = counts[WC_LENGTH];
}
totals[WC_LENGTH] -= counts[WC_LENGTH];
bb_fclose_nonstdin(fp);
OUTPUT:
s = fmt_str + 1; /* Skip the leading space on 1st pass. */
u = 0;
@@ -202,16 +202,16 @@ int wc_main(int argc, char **argv)
}
totals[u] += pcounts[u];
} while (++u < 4);
s += 8; /* Set the format to the empty string. */
if (*argv != bb_msg_standard_input) {
s -= 3; /* We have a name, so do %s conversion. */
}
bb_printf(s, *argv);
} while (*++argv);
/* If more than one file was processed, we want the totals. To save some
* space, we set the pcounts ptr to the totals array. This has the side
* effect of trashing the totals array after outputting it, but that's
@@ -222,6 +222,6 @@ int wc_main(int argc, char **argv)
pcounts = totals;
goto OUTPUT;
}
bb_fflush_stdout_and_exit(status);
}

View File

@@ -1,6 +1,6 @@
/* vi: set sw=4 ts=4: */
/*----------------------------------------------------------------------
* Mini who is used to display user name, login time,
* Mini who is used to display user name, login time,
* idle time and host name.
*
* Author: Da Chen <dchen@ayrnetworks.com>
@@ -10,7 +10,7 @@
* as published by the Free Software Foundation:
* http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2002 AYR Networks, Inc.
* Copyright (c) 2002 AYR Networks, Inc.
*----------------------------------------------------------------------
*/
@@ -30,21 +30,21 @@ extern int who_main(int argc, char **argv)
struct utmp *ut;
struct stat st;
int devlen, len;
time_t now, idle;
time_t now, idle;
if (argc > 1)
if (argc > 1)
bb_show_usage();
setutent();
devlen = sizeof("/dev/") - 1;
printf("USER TTY IDLE FROM HOST\n");
printf("USER TTY IDLE FROM HOST\n");
while ((ut = getutent()) != NULL) {
char name[40];
if (ut->ut_user[0] && ut->ut_type == USER_PROCESS) {
if (ut->ut_user[0] && ut->ut_type == USER_PROCESS) {
len = strlen(ut->ut_line);
if (ut->ut_line[0] == '/') {
if (ut->ut_line[0] == '/') {
strncpy(name, ut->ut_line, len);
name[len] = '\0';
strcpy(ut->ut_line, ut->ut_line + devlen);
@@ -53,27 +53,27 @@ extern int who_main(int argc, char **argv)
strncpy(name+devlen, ut->ut_line, len);
name[devlen+len] = '\0';
}
printf("%-10s %-8s ", ut->ut_user, ut->ut_line);
if (stat(name, &st) == 0) {
now = time(NULL);
now = time(NULL);
idle = now - st.st_atime;
if (idle < 60)
printf("00:00m ");
else if (idle < (60 * 60))
else if (idle < (60 * 60))
printf("00:%02dm ", (int)(idle / 60));
else if (idle < (24 * 60 * 60))
else if (idle < (24 * 60 * 60))
printf("%02d:%02dm ", (int)(idle / (60 * 60)),
(int)(idle % (60 * 60)) / 60);
else if (idle < (24 * 60 * 60 * 365))
else if (idle < (24 * 60 * 60 * 365))
printf("%03ddays ", (int)(idle / (24 * 60 * 60)));
else
else
printf("%02dyears ", (int) (idle / (24 * 60 * 60 * 365)));
} else
printf("%-8s ", "?");
} else
printf("%-8s ", "?");
printf("%-12.12s %s\n", ctime(&(ut->ut_tv.tv_sec)) + 4, ut->ut_host);
}
}