Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/csh ANSIfication and KNF improvements by Petri Koistinen...



details:   https://anonhg.NetBSD.org/src/rev/065893a2f310
branches:  trunk
changeset: 514946:065893a2f310
user:      wiz <wiz%NetBSD.org@localhost>
date:      Fri Sep 14 14:03:59 2001 +0000

description:
ANSIfication and KNF improvements by Petri Koistinen in bin/13689,
with some fixes by me.

diffstat:

 bin/csh/alloc.c     |   42 +--
 bin/csh/char.c      |    4 +-
 bin/csh/char.h      |   15 +-
 bin/csh/const.c     |    4 +-
 bin/csh/csh.c       |  440 +++++++++++++++++--------------------
 bin/csh/csh.h       |  308 +++++++++++++-------------
 bin/csh/dir.c       |  203 +++++++---------
 bin/csh/dir.h       |    7 +-
 bin/csh/dol.c       |  187 +++++++---------
 bin/csh/err.c       |   39 +-
 bin/csh/exec.c      |  220 ++++++++----------
 bin/csh/exp.c       |  223 +++++++-----------
 bin/csh/extern.h    |  408 +++++++++++++++++-----------------
 bin/csh/file.c      |  280 +++++++++++-------------
 bin/csh/func.c      |  599 +++++++++++++++++++++------------------------------
 bin/csh/glob.c      |  286 +++++++++++-------------
 bin/csh/hist.c      |   61 ++--
 bin/csh/init.c      |    9 +-
 bin/csh/lex.c       |  337 ++++++++++++-----------------
 bin/csh/misc.c      |  199 +++++++---------
 bin/csh/parse.c     |  190 +++++----------
 bin/csh/pathnames.h |    7 +-
 bin/csh/proc.c      |  433 ++++++++++++++++--------------------
 bin/csh/proc.h      |   25 +-
 bin/csh/sem.c       |  193 +++++++---------
 bin/csh/set.c       |  199 ++++++----------
 bin/csh/str.c       |  158 +++++-------
 bin/csh/strpct.c    |   14 +-
 bin/csh/time.c      |  200 +++++++---------
 29 files changed, 2359 insertions(+), 2931 deletions(-)

diffs (truncated from 11972 to 300 lines):

diff -r 84410f30441c -r 065893a2f310 bin/csh/alloc.c
--- a/bin/csh/alloc.c   Fri Sep 14 13:46:42 2001 +0000
+++ b/bin/csh/alloc.c   Fri Sep 14 14:03:59 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: alloc.c,v 1.9 1998/07/28 11:41:41 mycroft Exp $        */
+/* $NetBSD: alloc.c,v 1.10 2001/09/14 14:03:59 wiz Exp $ */
 
 /*-
  * Copyright (c) 1983, 1991, 1993
@@ -38,13 +38,15 @@
 #if 0
 static char sccsid[] = "@(#)alloc.c    8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: alloc.c,v 1.9 1998/07/28 11:41:41 mycroft Exp $");
+__RCSID("$NetBSD: alloc.c,v 1.10 2001/09/14 14:03:59 wiz Exp $");
 #endif
 #endif /* not lint */
 
 #include <sys/types.h>
+
 #include <unistd.h>
 #include <stdlib.h>
+
 #if __STDC__
 # include <stdarg.h>
 #else
@@ -54,14 +56,13 @@
 #include "csh.h"
 #include "extern.h"
 
-char   *memtop = NULL;         /* PWP: top of current memory */
-char   *membot = NULL;         /* PWP: bottom of allocatable memory */
+char *memtop = NULL;           /* PWP: top of current memory */
+char *membot = NULL;           /* PWP: bottom of allocatable memory */
 
 ptr_t
-Malloc(n)
-    size_t  n;
+Malloc(size_t n)
 {
-    ptr_t   ptr;
+    ptr_t ptr;
 
     if (membot == NULL)
        memtop = membot = sbrk(0);
@@ -73,11 +74,9 @@
 }
 
 ptr_t
-Realloc(p, n)
-    ptr_t   p;
-    size_t  n;
+Realloc(ptr_t p, size_t n)
 {
-    ptr_t   ptr;
+    ptr_t ptr;
 
     if (membot == NULL)
        memtop = membot = sbrk(0);
@@ -89,10 +88,9 @@
 }
 
 ptr_t
-Calloc(s, n)
-    size_t  s, n;
+Calloc(size_t s, size_t n)
 {
-    ptr_t   ptr;
+    ptr_t ptr;
 
     if (membot == NULL)
        memtop = membot = sbrk(0);
@@ -100,13 +98,11 @@
        child++;
        stderror(ERR_NOMEM);
     }
-
     return (ptr);
 }
 
 void
-Free(p)
-    ptr_t   p;
+Free(ptr_t p)
 {
     if (p)
        free(p);
@@ -121,12 +117,10 @@
  */
 void
 /*ARGSUSED*/
-showall(v, t)
-    Char **v;
-    struct command *t;
+showall(Char **v, struct command *t)
 {
-    memtop = (char *) sbrk(0);
-    (void) fprintf(cshout, "Allocated memory from 0x%lx to 0x%lx (%ld).\n",
-           (unsigned long) membot, (unsigned long) memtop, 
-           (unsigned long) (memtop - membot));
+    memtop = (char *)sbrk(0);
+    (void)fprintf(cshout, "Allocated memory from 0x%lx to 0x%lx (%ld).\n",
+           (unsigned long)membot, (unsigned long)memtop, 
+           (unsigned long)(memtop - membot));
 }
diff -r 84410f30441c -r 065893a2f310 bin/csh/char.c
--- a/bin/csh/char.c    Fri Sep 14 13:46:42 2001 +0000
+++ b/bin/csh/char.c    Fri Sep 14 14:03:59 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: char.c,v 1.7 1997/07/04 21:23:51 christos Exp $        */
+/* $NetBSD: char.c,v 1.8 2001/09/14 14:03:59 wiz Exp $ */
 
 /*-
  * Copyright (c) 1980, 1991, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)char.c     8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: char.c,v 1.7 1997/07/04 21:23:51 christos Exp $");
+__RCSID("$NetBSD: char.c,v 1.8 2001/09/14 14:03:59 wiz Exp $");
 #endif
 #endif /* not lint */
 
diff -r 84410f30441c -r 065893a2f310 bin/csh/char.h
--- a/bin/csh/char.h    Fri Sep 14 13:46:42 2001 +0000
+++ b/bin/csh/char.h    Fri Sep 14 14:03:59 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: char.h,v 1.6 1995/03/21 09:02:29 cgd Exp $     */
+/* $NetBSD: char.h,v 1.7 2001/09/14 14:03:59 wiz Exp $ */
 
 /*-
  * Copyright (c) 1980, 1991, 1993
@@ -35,6 +35,9 @@
  *     @(#)char.h      8.1 (Berkeley) 5/31/93
  */
 
+#ifndef _CHAR_H_
+#define _CHAR_H_
+
 #include <ctype.h>
 
 extern unsigned short _cmap[];
@@ -89,10 +92,12 @@
 #define Isalpha(c)     (cmap(c,_LET) && !(((c) & META) && AsciiOnly))
 #define Islower(c)     (cmap(c,_LOW) && !(((c) & META) && AsciiOnly))
 #define Isupper(c)     (cmap(c, _UP) && !(((c) & META) && AsciiOnly))
-#define Tolower(c)  (_cmap_lower[(unsigned char)(c)])
-#define Toupper(c)  (_cmap_upper[(unsigned char)(c)])
+#define Tolower(c)     (_cmap_lower[(unsigned char)(c)])
+#define Toupper(c)     (_cmap_upper[(unsigned char)(c)])
 #define Isxdigit(c)    cmap(c, _XD)
 #define Isalnum(c)     (cmap(c, _DIG|_LET) && !(((c) & META) && AsciiOnly))
-#define Iscntrl(c)  (cmap(c,_CTR) && !(((c) & META) && AsciiOnly))
-#define Isprint(c)  (!cmap(c,_CTR) && !(((c) & META) && AsciiOnly))
+#define Iscntrl(c)     (cmap(c,_CTR) && !(((c) & META) && AsciiOnly))
+#define Isprint(c)     (!cmap(c,_CTR) && !(((c) & META) && AsciiOnly))
 #endif
+
+#endif /* !_CHAR_H_ */
diff -r 84410f30441c -r 065893a2f310 bin/csh/const.c
--- a/bin/csh/const.c   Fri Sep 14 13:46:42 2001 +0000
+++ b/bin/csh/const.c   Fri Sep 14 14:03:59 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: const.c,v 1.7 1997/07/04 21:23:52 christos Exp $       */
+/* $NetBSD: const.c,v 1.8 2001/09/14 14:03:59 wiz Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)const.c    8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: const.c,v 1.7 1997/07/04 21:23:52 christos Exp $");
+__RCSID("$NetBSD: const.c,v 1.8 2001/09/14 14:03:59 wiz Exp $");
 #endif
 #endif /* not lint */
 
diff -r 84410f30441c -r 065893a2f310 bin/csh/csh.c
--- a/bin/csh/csh.c     Fri Sep 14 13:46:42 2001 +0000
+++ b/bin/csh/csh.c     Fri Sep 14 14:03:59 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: csh.c,v 1.26 2000/09/04 17:48:14 christos Exp $        */
+/* $NetBSD: csh.c,v 1.27 2001/09/14 14:03:59 wiz Exp $ */
 
 /*-
  * Copyright (c) 1980, 1991, 1993
@@ -43,23 +43,25 @@
 #if 0
 static char sccsid[] = "@(#)csh.c      8.2 (Berkeley) 10/12/93";
 #else
-__RCSID("$NetBSD: csh.c,v 1.26 2000/09/04 17:48:14 christos Exp $");
+__RCSID("$NetBSD: csh.c,v 1.27 2001/09/14 14:03:59 wiz Exp $");
 #endif
 #endif /* not lint */
 
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
+
+#include <errno.h>
 #include <fcntl.h>
-#include <errno.h>
+#include <locale.h>
+#include <paths.h>     /* should this be included in pathnames.h instead? */
 #include <pwd.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
-#include <locale.h>
 #include <unistd.h>
 #include <vis.h>
-#include <paths.h>     /* should this be included in pathnames.h instead? */
+
 #if __STDC__
 # include <stdarg.h>
 #else
@@ -67,9 +69,9 @@
 #endif
 
 #include "csh.h"
-#include "proc.h"
 #include "extern.h"
 #include "pathnames.h"
+#include "proc.h"
 
 /*
  * C Shell
@@ -84,49 +86,46 @@
  * June, 1991
  */
 
-Char   *dumphist[] = {STRhistory, STRmh, 0, 0};
-Char   *loadhist[] = {STRsource, STRmh, STRtildothist, 0};
+Char *dumphist[] = {STRhistory, STRmh, 0, 0};
+Char *loadhist[] = {STRsource, STRmh, STRtildothist, 0};
 
-int     nofile = 0;
-bool    reenter = 0;
-bool    nverbose = 0;
-bool    nexececho = 0;
-bool    quitit = 0;
-bool    fast = 0;
-bool    batch = 0;
-bool    mflag = 0;
-bool    prompt = 1;
-bool    enterhist = 0;
+int nofile = 0;
+bool batch = 0;
+bool enterhist = 0;
+bool fast = 0;
+bool mflag = 0;
+bool nexececho = 0;
+bool nverbose = 0;
+bool prompt = 1;
+bool quitit = 0;
+bool reenter = 0;
 
 extern char **environ;
 
-static int     readf __P((void *, char *, int));
-static fpos_t  seekf __P((void *, fpos_t, int));
-static int     writef __P((void *, const char *, int));
-static int     closef __P((void *));
-static int     srccat __P((Char *, Char *));
-static int     srcfile __P((char *, bool, bool));
-static void    phup __P((int));
-static void    srcunit __P((int, bool, bool));
-static void    mailchk __P((void));
+static int readf(void *, char *, int);
+static fpos_t seekf(void *, fpos_t, int);
+static int writef(void *, const char *, int);
+static int closef(void *);
+static int srccat(Char *, Char *);
+static int srcfile(char *, bool, bool);
+static void phup(int);
+static void srcunit(int, bool, bool);
+static void mailchk(void);
 #ifndef _PATH_DEFPATH
-static Char   **defaultpath __P((void));
+static Char **defaultpath(void);
 #endif
 
-int main __P((int, char **));
+int main(int, char *[]);
 
 int
-main(argc, argv)
-    int     argc;
-    char  **argv;
+main(int argc, char *argv[])
 {
+    struct sigaction oact;
     Char *cp;
-    char *tcp;
+    char *tcp, **tempv;
     const char *ecp;
+    sigset_t sigset;
     int f;
-    char **tempv;
-    struct sigaction oact;



Home | Main Index | Thread Index | Old Index