Check-in [843d2adf7c]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Eliminate warnings with -Wall; need to eliminate externs and fn decls from C files
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:843d2adf7ccc05d08d1c6ba5ea657d08b1e25e95
User & Date: darrenbane 2014-10-21 21:40:36
Context
2014-10-22
16:50
Add externs.h that I forgot about check-in: 1e3cc4438c user: darrenbane tags: trunk
2014-10-21
21:40
Eliminate warnings with -Wall; need to eliminate externs and fn decls from C files check-in: 843d2adf7c user: darrenbane tags: trunk
2014-10-15
18:54
Run through cppcheck check-in: af7f96faac user: darrenbane tags: trunk
Changes

Changes to hdr/find.h.

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 */

#ifndef _FIND_H_
#define _FIND_H_

/**
 * Find a label by name.
 * @public @memberof Type
 * @param tp the type of label to find
 * @param name the label name
 * @return a pointer to the label struct; or NULL if it can't be found
 */
Label *typeFindlabel(Type *tp, char *name);

/**







<







3
4
5
6
7
8
9

10
11
12
13
14
15
16
 */

#ifndef _FIND_H_
#define _FIND_H_

/**
 * Find a label by name.

 * @param tp the type of label to find
 * @param name the label name
 * @return a pointer to the label struct; or NULL if it can't be found
 */
Label *typeFindlabel(Type *tp, char *name);

/**

Changes to hdr/printl.h.

3
4
5
6
7
8
9
10
11
12
13
14
15
16
 */

#ifndef _PRINTL_H_
#define _PRINTL_H_

/**
 * @brief Print a label.
 * @public @memberof Label
 * @param lab label to print.
 * @param out file handle to output on.
 */
void	labelPrint(Label *lab, FILE *out);

#endif







<






3
4
5
6
7
8
9

10
11
12
13
14
15
 */

#ifndef _PRINTL_H_
#define _PRINTL_H_

/**
 * @brief Print a label.

 * @param lab label to print.
 * @param out file handle to output on.
 */
void	labelPrint(Label *lab, FILE *out);

#endif

Changes to hdr/types.h.

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59



60
61
62
63
64
65
66
/** @todo Remove this */
#define	us		unsigned

/** Max no. of header levels */
#define	NLEVELS	20

/** Type for header levels member of label struct */
typedef us int levels[NLEVELS];

/** Header format */
typedef char *format;

typedef struct Type Type;       /**< Type type */
typedef struct Label Label;     /**< Label type */
typedef struct Keyword Keyword; /**< Keyword type */

/** Label type */
struct Type {
	char   *t_name;	/**< name */
	levels	t_levels;	/**< current header levels */
	format	t_format;   /**< format */
        LIST_HEAD(, Label) labelhead;   /**< list of labels of this type */
        LIST_ENTRY(Type) link;  /**< next type in list of types */
};

/** Label definition */
struct Label {
	char   *l_name; /**< Name */
	Type   *l_type; /**< Back-reference to label type */
	levels	l_levels;   /**< Counter for label no. at different levels */
	us int	l_bottom;		/**< Last significant level */
	char   *l_file;			/**< File where defined */
	long	l_line;			/**< line where defined */
        LIST_ENTRY(Label) link; /**< Next label in list of labels */



};

/** Action routine for keyword processing */
typedef int (*func) ();

/** Command keyword, to come after ".L=" at the start of an input line */
struct Keyword {







|













|







<
<



>
>
>







26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54


55
56
57
58
59
60
61
62
63
64
65
66
67
/** @todo Remove this */
#define	us		unsigned

/** Max no. of header levels */
#define	NLEVELS	20

/** Type for header levels member of label struct */
typedef int levels[NLEVELS];

/** Header format */
typedef char *format;

typedef struct Type Type;       /**< Type type */
typedef struct Label Label;     /**< Label type */
typedef struct Keyword Keyword; /**< Keyword type */

/** Label type */
struct Type {
	char   *t_name;	/**< name */
	levels	t_levels;	/**< current header levels */
	format	t_format;   /**< format */
        LIST_HEAD(labelhead_t, Label) labelhead;   /**< list of labels of this type */
        LIST_ENTRY(Type) link;  /**< next type in list of types */
};

/** Label definition */
struct Label {
	char   *l_name; /**< Name */
	Type   *l_type; /**< Back-reference to label type */


	char   *l_file;			/**< File where defined */
	long	l_line;			/**< line where defined */
        LIST_ENTRY(Label) link; /**< Next label in list of labels */
	levels	l_levels;   /**< Counter for label no. at different levels */
	int	l_bottom;		/**< Last significant level */
	unsigned char padding[4];
};

/** Action routine for keyword processing */
typedef int (*func) ();

/** Command keyword, to come after ".L=" at the start of an input line */
struct Keyword {

Deleted mk/check.mk.

1
2
.PHONY: clangcheck
	
<
<




Changes to src/Makefile.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
PREFIX?= /home/dbane
BINDIR= $(PREFIX)/bin
MANDIR= $(PREFIX)/man/man
PROG= lbl

# Need _DARWIN_C_SOURCE for strlcpy/strlcat
#CFLAGS+= -I../hdr -Wall -std=c11 -D_XOPEN_SOURCE=600 -D_DARWIN_C_SOURCE
CFLAGS+= -I../hdr -Wall -std=c11

MAN= ../doc/lbl.1
SRCS= lbl.c actions.c build.c externs.c find.c keyword.c list.c \
      printl.c rescan.c scan.c signals.c
LIBC= /usr/lib/libSystem.dylib

.include <bsd.prog.mk>
#.include "check.mk"







|







<
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

PREFIX?= /home/dbane
BINDIR= $(PREFIX)/bin
MANDIR= $(PREFIX)/man/man
PROG= lbl

# Need _DARWIN_C_SOURCE for strlcpy/strlcat
#CFLAGS+= -I../hdr -Wall -std=c11 -D_XOPEN_SOURCE=600 -D_DARWIN_C_SOURCE
CFLAGS+= -I../hdr -Weverything -std=c11

MAN= ../doc/lbl.1
SRCS= lbl.c actions.c build.c externs.c find.c keyword.c list.c \
      printl.c rescan.c scan.c signals.c
LIBC= /usr/lib/libSystem.dylib

.include <bsd.prog.mk>

Changes to src/actions.c.

19
20
21
22
23
24
25

26
27
28
29
30
31

32
33
34
35
36
37
38
..
43
44
45
46
47
48
49

50
51
52
53
54
55
56
57

58
59
60
61
62

63
64
65
66
67
68
69
#include        "build.h"
#include        "find.h"

extern char *def_format;
extern int sflag;
extern FILE *tempfile;


/*ARGSUSED*/
void
a_delimiter(nargs, argvec)
	int nargs;
	char *argvec[];
{

	if (strcmp(argvec[1], "off") == 0) {
		if (!sflag)
			fprintf(tempfile, "%c%c%c\n", MAGIC1, MAGIC2, M_DELIM);
		return;
	}
	if (argvec[1][1] != '\0') {
		warnx("%sdelimiter more than 1 character", maybe_loc());
................................................................................
		return;
	}
	if (!sflag)
		fprintf(tempfile, "%c%c%c%c\n", MAGIC1, MAGIC2,
		    M_DELIM, argvec[1][0]);
}


/*ARGSUSED*/
void
a_format(nargs, argvec)
	int nargs;
	char *argvec[];
{
	Type *tp = findtype(argvec[1], 1);


	if (tp->t_format != def_format)
		warnx("%s[warning] format for %s redefined", maybe_loc(), tp->t_name);
	tp->t_format = copy(argvec[2]);
}


/*ARGSUSED*/
void
a_last(nargs, argvec)
	int nargs;
	char *argvec[];
{
	Type *tp = findtype(argvec[1], 1);







>






>







 







>








>





>







19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
..
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include        "build.h"
#include        "find.h"

extern char *def_format;
extern int sflag;
extern FILE *tempfile;

void a_delimiter(int nargs, char *argvec[]);
/*ARGSUSED*/
void
a_delimiter(nargs, argvec)
	int nargs;
	char *argvec[];
{
        (void)nargs;
	if (strcmp(argvec[1], "off") == 0) {
		if (!sflag)
			fprintf(tempfile, "%c%c%c\n", MAGIC1, MAGIC2, M_DELIM);
		return;
	}
	if (argvec[1][1] != '\0') {
		warnx("%sdelimiter more than 1 character", maybe_loc());
................................................................................
		return;
	}
	if (!sflag)
		fprintf(tempfile, "%c%c%c%c\n", MAGIC1, MAGIC2,
		    M_DELIM, argvec[1][0]);
}

void a_format(int nargs, char *argvec[]);
/*ARGSUSED*/
void
a_format(nargs, argvec)
	int nargs;
	char *argvec[];
{
	Type *tp = findtype(argvec[1], 1);

        (void)nargs;
	if (tp->t_format != def_format)
		warnx("%s[warning] format for %s redefined", maybe_loc(), tp->t_name);
	tp->t_format = copy(argvec[2]);
}

void a_last(int nargs, char *argvec[]);
/*ARGSUSED*/
void
a_last(nargs, argvec)
	int nargs;
	char *argvec[];
{
	Type *tp = findtype(argvec[1], 1);

Changes to src/build.c.

17
18
19
20
21
22
23

24
25
26
27
28
29
30
31
32
33
34
35
..
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include        "find.h"

extern char *def_format;
extern char *filename;
extern long fileline;
extern LIST_HEAD(, Type) typehead;


char   *
alloc(nbytes)
	us int nbytes;
{
	char *ptr = malloc(nbytes);

	if (ptr == NULL)
		errx(EX_OSERR, "%sran out of memory space", maybe_loc());
	return ptr;
}

char   *
................................................................................
addlbl(lbltype, lbllevel, lblname)
	char *lbltype;
	char *lbllevel;
	char *lblname;
{
	Type *tp = findtype(lbltype, 1);
	Label *last_next;
	us int bottom;
	us int indx;

	if (!isdigit(lbllevel[0])) {
		warnx("%snon-numeric index level", maybe_loc());
		return;
	}
	if ((bottom = atoi(lbllevel)) == 0 || bottom > NLEVELS) {
		warnx("%sindex level must be in range 1-%u", maybe_loc(), NLEVELS);
		return;
	}
	bottom--;

	++(tp->t_levels[bottom]);
	for (indx = bottom + 1; indx < NLEVELS; indx++)







>
|

|

|







 







|
|





|







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
..
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include        "find.h"

extern char *def_format;
extern char *filename;
extern long fileline;
extern LIST_HEAD(, Type) typehead;

static void *alloc(unsigned long nbytes);
static void   *
alloc(nbytes)
	unsigned long nbytes;
{
	void *ptr = malloc(nbytes);

	if (ptr == NULL)
		errx(EX_OSERR, "%sran out of memory space", maybe_loc());
	return ptr;
}

char   *
................................................................................
addlbl(lbltype, lbllevel, lblname)
	char *lbltype;
	char *lbllevel;
	char *lblname;
{
	Type *tp = findtype(lbltype, 1);
	Label *last_next;
	int bottom;
	int indx;

	if (!isdigit(lbllevel[0])) {
		warnx("%snon-numeric index level", maybe_loc());
		return;
	}
	if ((bottom = atoi(lbllevel)) <= 0 || bottom > NLEVELS) {
		warnx("%sindex level must be in range 1-%u", maybe_loc(), NLEVELS);
		return;
	}
	bottom--;

	++(tp->t_levels[bottom]);
	for (indx = bottom + 1; indx < NLEVELS; indx++)

Changes to src/externs.c.

4
5
6
7
8
9
10

11
12
13
14
15
16
17
18
19
20
21
22
 *	software freely, provided that this notice be retained,
 *	and that no use be made of the software for commercial
 *	purposes without the express written permission of the
 *	author.
 */

#include	<lbl.h>


char	delimiter = '@';
char	macroname[] = "L=";
char	tempname[] = "/tmp/lblXXXXXX";
char   *def_format = STDFORM;
char   *progname = "lbl";
char   *filename = NULL;
int	lflag = 0;
int	sflag = 0;
FILE   *tempfile = NULL;
long	fileline;
LIST_HEAD(, Type) typehead = LIST_HEAD_INITIALIZER(typehead);







>











|
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 *	software freely, provided that this notice be retained,
 *	and that no use be made of the software for commercial
 *	purposes without the express written permission of the
 *	author.
 */

#include	<lbl.h>
#include	"externs.h"

char	delimiter = '@';
char	macroname[] = "L=";
char	tempname[] = "/tmp/lblXXXXXX";
char   *def_format = STDFORM;
char   *progname = "lbl";
char   *filename = NULL;
int	lflag = 0;
int	sflag = 0;
FILE   *tempfile = NULL;
long	fileline;
struct typehead_t typehead = LIST_HEAD_INITIALIZER(typehead);

Changes to src/keyword.c.

9
10
11
12
13
14
15

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40

/* keyword.c:
 *	look up a command keyword (by sequential search).
 */

#include        <string.h>
#include	<lbl.h>


extern int a_delimiter();
extern int a_format();
extern int a_last();

Keyword	keytable[] =
{
	{"delimiter", a_delimiter, 2, 2},
	{"format", a_format, 3, 3},
	{"last", a_last, 3, 22}
};

#define NKEYS	(sizeof(keytable) / sizeof(Keyword))

Keyword *
findkeyword(word)
	char *word;
{
	int indx;

	for (indx = 0; indx < NKEYS; indx++)
		if (strcmp(word, keytable[indx].k_name) == 0)
			return keytable + indx;
	return NULL;
}







>





|












|






9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41

/* keyword.c:
 *	look up a command keyword (by sequential search).
 */

#include        <string.h>
#include	<lbl.h>
#include	"keyword.h"

extern int a_delimiter();
extern int a_format();
extern int a_last();

static Keyword	keytable[] =
{
	{"delimiter", a_delimiter, 2, 2},
	{"format", a_format, 3, 3},
	{"last", a_last, 3, 22}
};

#define NKEYS	(sizeof(keytable) / sizeof(Keyword))

Keyword *
findkeyword(word)
	char *word;
{
	unsigned long indx;

	for (indx = 0; indx < NKEYS; indx++)
		if (strcmp(word, keytable[indx].k_name) == 0)
			return keytable + indx;
	return NULL;
}

Changes to src/lbl.c.

28
29
30
31
32
33
34

35


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
...
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
...
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#include        <limits.h>
#include        <assert.h>
#include        "lbl.h"
#include        "signals.h"
#include        "scan.h"
#include        "rescan.h"
#include	"list.h"




/** Size of macroname[] */
const int MACRONAME_MAX = 3;

extern int lflag;
extern int sflag;
extern char delimiter;
extern char macroname[];
extern char tempname[];
extern char *progname;
extern FILE *tempfile;
extern char *filename;
extern long fileline;

int
main(argc, argv)
	int argc;
	char *argv[];
{
	us int decode();
	us int nflags;
	int anydone = 0;
	static char standard[] = "standard input";

	if (argc != 0) {
		argc--;
		progname = *(argv++);
	}
................................................................................
		rescan();
		unlink(tempname);
	}
	exit(0);
}

/* Decode argument list */
us int
decode(argc, argv)
	us int argc;
	char *argv[];
{
        int ch;
	int nflags = 0;
   
        while ((ch = getopt(argc, argv, ":d:m:ls")) != -1) {
                switch (ch) {
................................................................................
		        break;
		case ':':
		        assert(optopt == 'd' || optopt == 'm');
		        switch (optopt) {
			case 'd':
			        errx(EX_USAGE, "%smissing delimiter after -d", maybe_loc());
		   		/* NOTREACHED */
			        break;
			case 'm':
				errx(
				    EX_USAGE, "%smacro name must be 2 characters", maybe_loc());
		   		/* NOTREACHED */
			}
		        break;
		case '?':







>

>
>

|
<
<
<
<
<
<
<
<
<
<






<
|







 







|

|







 







<







28
29
30
31
32
33
34
35
36
37
38
39
40










41
42
43
44
45
46

47
48
49
50
51
52
53
54
...
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
...
141
142
143
144
145
146
147

148
149
150
151
152
153
154
#include        <limits.h>
#include        <assert.h>
#include        "lbl.h"
#include        "signals.h"
#include        "scan.h"
#include        "rescan.h"
#include	"list.h"
#include	"externs.h"

int decode(int argc, char *argv[]);

/** Size of macroname[] */
static const int MACRONAME_MAX = 3;











int
main(argc, argv)
	int argc;
	char *argv[];
{

	int nflags;
	int anydone = 0;
	static char standard[] = "standard input";

	if (argc != 0) {
		argc--;
		progname = *(argv++);
	}
................................................................................
		rescan();
		unlink(tempname);
	}
	exit(0);
}

/* Decode argument list */
int
decode(argc, argv)
	int argc;
	char *argv[];
{
        int ch;
	int nflags = 0;
   
        while ((ch = getopt(argc, argv, ":d:m:ls")) != -1) {
                switch (ch) {
................................................................................
		        break;
		case ':':
		        assert(optopt == 'd' || optopt == 'm');
		        switch (optopt) {
			case 'd':
			        errx(EX_USAGE, "%smissing delimiter after -d", maybe_loc());
		   		/* NOTREACHED */

			case 'm':
				errx(
				    EX_USAGE, "%smacro name must be 2 characters", maybe_loc());
		   		/* NOTREACHED */
			}
		        break;
		case '?':

Changes to src/printl.c.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
..
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
 *	author.
 */

#include        <err.h>
#include	<lbl.h>
#include        "printl.h"

void	printr(char, us int, FILE *);
static void printd(us int, FILE *);
static void printa(char, us int, FILE *);
static void auxprinta(char, us int, FILE *);

void
labelPrint(lab, out)
	rg Label *lab;
	rg FILE *out;
{
	rg format f = lab->l_type->t_format;
	rg us int i;

	for (i = 0; i <= lab->l_bottom; i++) {
		while (*f) {
			if (*f != '%')
				putc(*f, out);
			else
				switch (*++f) {
................................................................................
		continue;
	}
}

/* Print Decimal */
void
printd(n, out)
	unsigned int n;
	FILE *out;
{
	fprintf(out, "%u", n);
}

/* Print Alphabetic
 *	actually base 26 (digits a-z), displaced by 1!
 *	a is either "a" or "A" for upper or lower case.
 */
void
printa(char a, us int n, FILE *out)
{
	if (n == 0)
		putc('0', out);
	else
		auxprinta(a, n - 1, out);
}

void
auxprinta(char a, us int n, FILE *out)
{
	if (n > 25)
		auxprinta(a, n / 26 - 1, out);
	putc(a + n % 26, out);
}

/* Print Roman
 *	a is either "a" or "A" for upper or lower case.
 */
void
printr(char a, us int n, FILE *out)
{
	if (n == 0) {
		putc('0', out);
		return;
	}
	if (n >= 50000) {
		putc('!', out);







|
|
|
|







|







 







|










|








|



|






|







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
..
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
 *	author.
 */

#include        <err.h>
#include	<lbl.h>
#include        "printl.h"

void	printr(char, int, FILE *);
static void printd(int, FILE *);
static void printa(char, int, FILE *);
static void auxprinta(char, int, FILE *);

void
labelPrint(lab, out)
	rg Label *lab;
	rg FILE *out;
{
	rg format f = lab->l_type->t_format;
	rg int i;

	for (i = 0; i <= lab->l_bottom; i++) {
		while (*f) {
			if (*f != '%')
				putc(*f, out);
			else
				switch (*++f) {
................................................................................
		continue;
	}
}

/* Print Decimal */
void
printd(n, out)
	int n;
	FILE *out;
{
	fprintf(out, "%u", n);
}

/* Print Alphabetic
 *	actually base 26 (digits a-z), displaced by 1!
 *	a is either "a" or "A" for upper or lower case.
 */
void
printa(char a, int n, FILE *out)
{
	if (n == 0)
		putc('0', out);
	else
		auxprinta(a, n - 1, out);
}

void
auxprinta(char a, int n, FILE *out)
{
	if (n > 25)
		auxprinta(a, n / 26 - 1, out);
	putc((int)a + n % 26, out);
}

/* Print Roman
 *	a is either "a" or "A" for upper or lower case.
 */
void
printr(char a, int n, FILE *out)
{
	if (n == 0) {
		putc('0', out);
		return;
	}
	if (n >= 50000) {
		putc('!', out);

Changes to src/rescan.c.

10
11
12
13
14
15
16

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
..
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
...
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#include	<lbl.h>
#include	<ctype.h>
#include        <string.h>
#include        <err.h>
#include        "find.h"
#include	"printl.h"
#include        "rescan.h"


void	doreplace(void);
static void domagic(void);
static void getword(rg char *buffer);

extern char delimiter;
extern char *filename;
extern FILE *tempfile;
extern long fileline;

int	translate = 1;

void
rescan()
{
	rg int c;

	/*
................................................................................
	switch (getc(tempfile)) {
	case M_DELIM:
		c = getc(tempfile);
		if (c == '\n')
			translate = 0;
		else {
			translate = 1;
			delimiter = c;
			getc(tempfile);
		}
		break;
	case M_FILE:
		fgets(buffer, BUFSIZ, tempfile);
		buffer[strlen(buffer) - 1] = '\0';
		filename = buffer;
................................................................................
	rg int dlm = delimiter;
	rg FILE *tf = tempfile;

	c = getc(tf);
	while (isspace(c))
		c = getc(tf);
	while (c != dlm && !isspace(c) && c != '\n' && c != EOF) {
		*buffer++ = c;
		c = getc(tf);
	}
	*buffer = '\0';
	if (!isspace(c) && c != EOF)
		ungetc(c, tf);
}







>





<
<
<
<
<
|







 







|







 







|






10
11
12
13
14
15
16
17
18
19
20
21
22





23
24
25
26
27
28
29
30
..
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
...
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#include	<lbl.h>
#include	<ctype.h>
#include        <string.h>
#include        <err.h>
#include        "find.h"
#include	"printl.h"
#include        "rescan.h"
#include	"externs.h"

void	doreplace(void);
static void domagic(void);
static void getword(rg char *buffer);






static int	translate = 1;

void
rescan()
{
	rg int c;

	/*
................................................................................
	switch (getc(tempfile)) {
	case M_DELIM:
		c = getc(tempfile);
		if (c == '\n')
			translate = 0;
		else {
			translate = 1;
			delimiter = (char)c;
			getc(tempfile);
		}
		break;
	case M_FILE:
		fgets(buffer, BUFSIZ, tempfile);
		buffer[strlen(buffer) - 1] = '\0';
		filename = buffer;
................................................................................
	rg int dlm = delimiter;
	rg FILE *tf = tempfile;

	c = getc(tf);
	while (isspace(c))
		c = getc(tf);
	while (c != dlm && !isspace(c) && c != '\n' && c != EOF) {
		*buffer++ = (char)c;
		c = getc(tf);
	}
	*buffer = '\0';
	if (!isspace(c) && c != EOF)
		ungetc(c, tf);
}

Changes to src/scan.c.

92
93
94
95
96
97
98

99
100
101
102
103
104
105

/* split - split a line into arguments
 *	N.B. successive calls of this invalidate earlier calls;
 *	argvec is set to point to strings within the
 *	static local buffer "copybuf" which is overwritten on
 *	each call.
 */

us int
split(line, argvec)
	char *line;
	char *argvec[];
{
	us int nargs = 0;
	static char copybuf[BUFSIZ];







>







92
93
94
95
96
97
98
99
100
101
102
103
104
105
106

/* split - split a line into arguments
 *	N.B. successive calls of this invalidate earlier calls;
 *	argvec is set to point to strings within the
 *	static local buffer "copybuf" which is overwritten on
 *	each call.
 */
us int split(char *line, char *argvec[]);
us int
split(line, argvec)
	char *line;
	char *argvec[];
{
	us int nargs = 0;
	static char copybuf[BUFSIZ];

Changes to src/signals.c.

12
13
14
15
16
17
18

19
20
21

22
23
24
25
26
27
28
#include        <unistd.h>
#include        "signals.h"

typedef void (*sig_t) (int);

extern char tempname[];


static void
onsignal(int unused)
{

	unlink(tempname);
	_exit(2);
}

void
setsignals()
{







>



>







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include        <unistd.h>
#include        "signals.h"

typedef void (*sig_t) (int);

extern char tempname[];

static void onsignal(int unused) __attribute__((noreturn));
static void
onsignal(int unused)
{
	(void)unused;
	unlink(tempname);
	_exit(2);
}

void
setsignals()
{