From owner-freebsd-bugs Mon Oct 7 21: 0:16 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9B23237B401 for ; Mon, 7 Oct 2002 21:00:12 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5113E43E42 for ; Mon, 7 Oct 2002 21:00:11 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id g9840BCo034901 for ; Mon, 7 Oct 2002 21:00:11 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id g9840B49034900; Mon, 7 Oct 2002 21:00:11 -0700 (PDT) Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D9E6937B406 for ; Mon, 7 Oct 2002 20:52:07 -0700 (PDT) Received: from www.freebsd.org (www.freebsd.org [216.136.204.117]) by mx1.FreeBSD.org (Postfix) with ESMTP id 90B2843EA3 for ; Mon, 7 Oct 2002 20:52:07 -0700 (PDT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.12.6/8.12.6) with ESMTP id g983q77R050254 for ; Mon, 7 Oct 2002 20:52:07 -0700 (PDT) (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.12.6/8.12.6/Submit) id g983q7bl050253; Mon, 7 Oct 2002 20:52:07 -0700 (PDT) Message-Id: <200210080352.g983q7bl050253@www.freebsd.org> Date: Mon, 7 Oct 2002 20:52:07 -0700 (PDT) From: Tim Kientzle To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-1.0 Subject: bin/43810: 'echo' is too big Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 43810 >Category: bin >Synopsis: 'echo' is too big >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Mon Oct 07 21:00:11 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Tim Kientzle >Release: FreeBSD-CURRENT >Organization: >Environment: >Description: Compiled, statically linked, and stripped, 'echo' is over 40k!! A few space-conscious edits reduce that to just over 5k. >How-To-Repeat: ls -l /bin/echo >Fix: Following patch reduces 'echo' to just over 5k with _no_lost_functionality_ (even that obscure \c hack still works): diff --context echo.c-original echo.c *** echo.c-original Mon Oct 7 20:44:50 2002 --- echo.c Mon Oct 7 20:44:15 2002 *************** *** 45,52 **** #include __FBSDID("$FreeBSD: src/bin/echo/echo.c,v 1.13 2002/06/30 05:13:53 obrien Exp $"); - #include - #include #include /* ARGSUSED */ --- 45,50 ---- *************** *** 56,62 **** int nflag; /* if not set, output a trailing newline. */ /* This utility may NOT do getopt(3) option parsing. */ ! if (*++argv && !strcmp(*argv, "-n")) { ++argv; nflag = 1; } --- 54,60 ---- int nflag; /* if not set, output a trailing newline. */ /* This utility may NOT do getopt(3) option parsing. */ ! if (*++argv && argv[0][0]=='-' && argv[0][1]=='n') { ++argv; nflag = 1; } *************** *** 64,69 **** --- 62,69 ---- nflag = 0; while (argv[0] != NULL) { + size_t len; + len = strlen(argv[0]); /* * If the next argument is NULL then this is this *************** *** 71,93 **** * for a trailing \c. */ if (argv[1] == NULL) { - size_t len; - - len = strlen(argv[0]); /* is there room for a '\c' and is there one? */ if (len >= 2 && argv[0][len - 2] == '\\' && argv[0][len - 1] == 'c') { /* chop it and set the no-newline flag. */ - argv[0][len - 2] = '\0'; nflag = 1; } } ! (void)printf("%s", argv[0]); if (*++argv) ! putchar(' '); } if (!nflag) ! putchar('\n'); return 0; } --- 71,90 ---- * for a trailing \c. */ if (argv[1] == NULL) { /* is there room for a '\c' and is there one? */ if (len >= 2 && argv[0][len - 2] == '\\' && argv[0][len - 1] == 'c') { /* chop it and set the no-newline flag. */ nflag = 1; + len -= 2; } } ! (void)write(1,argv[0],len); if (*++argv) ! write(1," ",1); } if (!nflag) ! write(1,"\n",1); return 0; } >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message