summaryrefslogtreecommitdiffstats
path: root/usr.bin/fsplit/fsplit.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/fsplit/fsplit.c')
-rw-r--r--usr.bin/fsplit/fsplit.c64
1 files changed, 42 insertions, 22 deletions
diff --git a/usr.bin/fsplit/fsplit.c b/usr.bin/fsplit/fsplit.c
index 19cc965..73a2b34 100644
--- a/usr.bin/fsplit/fsplit.c
+++ b/usr.bin/fsplit/fsplit.c
@@ -35,19 +35,25 @@
*/
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1983, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
+#if 0
static char sccsid[] = "@(#)fsplit.c 8.1 (Berkeley) 6/6/93";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
#include <ctype.h>
+#include <err.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <unistd.h>
/*
* usage: fsplit [-e efile] ... [file]
@@ -63,7 +69,7 @@ static char sccsid[] = "@(#)fsplit.c 8.1 (Berkeley) 6/6/93";
* If -e option is used, then only those subprograms named in the -e
* option are split off; e.g.:
* fsplit -esub1 -e sub2 prog.f
- * isolates sub1 and sub2 in sub1.f and sub2.f. The space
+ * isolates sub1 and sub2 in sub1.f and sub2.f. The space
* after -e is optional.
*
* Modified Feb., 1983 by Jerry Berkman, Computing Services, U.C. Berkeley.
@@ -80,7 +86,6 @@ FILE *ifp;
char x[]="zzz000.f",
mainp[]="main000.f",
blkp[]="blkdta000.f";
-char *look(), *skiplab(), *functs();
#define TRUE 1
#define FALSE 0
@@ -93,6 +98,18 @@ struct stat sbuf;
#define trim(p) while (*p == ' ' || *p == '\t') p++
+int getline __P((void));
+void get_name __P((char *, int));
+char *functs __P((char *));
+int lend __P((void));
+int lname __P((char *));
+char *look __P((char *, char *));
+int saveit __P((char *));
+int scan_name __P((char *, char *));
+char *skiplab __P((char *));
+static void usage __P((void));
+
+int
main(argc, argv)
char **argv;
{
@@ -112,7 +129,8 @@ char **argv;
if(!*ptr) {
argc--;
argv++;
- if(argc <= 1) badparms();
+ if(argc <= 1)
+ usage();
ptr = argv[1];
}
extrknt = extrknt + 1;
@@ -125,12 +143,10 @@ char **argv;
}
if (argc > 2)
- badparms();
+ usage();
else if (argc == 2) {
- if ((ifp = fopen(argv[1], "r")) == NULL) {
- fprintf(stderr, "fsplit: cannot open %s\n", argv[1]);
- exit(1);
- }
+ if ((ifp = fopen(argv[1], "r")) == NULL)
+ errx(1, "cannot open %s", argv[1]);
}
else
ifp = stdin;
@@ -155,8 +171,7 @@ char **argv;
for ( i = 0; i <= extrknt; i++ )
if(!extrfnd[i]) {
retval = 1;
- fprintf( stderr, "fsplit: %s not found\n",
- extrnames[i]);
+ warnx("%s not found", extrnames[i]);
}
exit( retval );
}
@@ -184,12 +199,14 @@ char **argv;
}
}
-badparms()
+static void
+usage()
{
- fprintf(stderr, "fsplit: usage: fsplit [-e efile] ... [file] \n");
+ fprintf(stderr, "usage: fsplit [-e efile] ... [file]\n");
exit(1);
}
+int
saveit(name)
char *name;
{
@@ -201,7 +218,7 @@ char *name;
while(*name) *fptr++ = *name++;
*--fptr = 0;
*--fptr = 0;
- for ( i=0 ; i<=extrknt; i++ )
+ for ( i=0 ; i<=extrknt; i++ )
if( strcmp(fname, extrnames[i]) == 0 ) {
extrfnd[i] = TRUE;
return(1);
@@ -209,6 +226,7 @@ char *name;
return(0);
}
+void
get_name(name, letters)
char *name;
int letters;
@@ -222,13 +240,12 @@ int letters;
break;
*ptr = '0';
}
- if(ptr < name + letters) {
- fprintf( stderr, "fsplit: ran out of file names\n");
- exit(1);
- }
+ if(ptr < name + letters)
+ errx(1, "ran out of file names");
}
}
+int
getline()
{
register char *ptr;
@@ -243,11 +260,12 @@ getline()
}
}
while (getc(ifp) != '\n' && feof(ifp) == 0) ;
- fprintf(stderr, "line truncated to %d characters\n", BSZ);
+ warnx("line truncated to %d characters", BSZ);
return (1);
}
/* return 1 for 'end' alone on card (up to col. 72), 0 otherwise */
+int
lend()
{
register char *p;
@@ -269,15 +287,16 @@ lend()
return (0);
}
-/* check for keywords for subprograms
+/* check for keywords for subprograms
return 0 if comment card, 1 if found
name and put in arg string. invent name for unnamed
block datas and main programs. */
+int
lname(s)
char *s;
{
-# define LINESIZE 80
- register char *ptr, *p, *sptr;
+# define LINESIZE 80
+ register char *ptr, *p;
char line[LINESIZE], *iptr = line;
/* first check for comment cards */
@@ -324,6 +343,7 @@ char *s;
return(1);
}
+int
scan_name(s, ptr)
char *s, *ptr;
{
OpenPOWER on IntegriCloud