aboutsummaryrefslogtreecommitdiff
path: root/sys/libc/zztest.c
blob: b43fe705c096959fd5ffb44f03c50df4408428fd (plain) (blame)
1
2
3
4
5
6
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
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
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
/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
 */

#define import_libc
#define import_stdio
#define import_spp
#define import_error
#define import_xwhen
#include <iraf.h>

thello_()
{
	fputs ("hello, world\n", stdout);
}


tprint_()
{
	char	buf[128];

	sprintf (buf, "\tabcdef %0*d[%-5.2s], %h\n", 5, 99, "wxyz", 12.5);
	fputs (buf, stdout);
}


tcopy_()
{
	FILE	*in, *out;
	int	ch;

	if ((in = fopen ("junk", "r")) == NULL)
	    c_erract (EA_ERROR);
	if ((out = fopen ("junk2", "wb")) == NULL)
	    c_erract (EA_ERROR);

	while ((ch = getc (in)) != EOF)
	    putc (ch, out);

	fclose (in);
	fclose (out);
}


tscan_()
{
	char	buf[SZ_LINE];
	char	str[SZ_LINE];
	char	cval;
	int	ival, nscan, n1, n2;
	int	onint(), oldint;
	double	dval;

	c_xwhen (X_INT, onint, &oldint);

	printf (">> \n");
	fflush (stdout);

	while (fgets (buf, SZ_LINE, stdin) != NULL) {
	    nscan = sscanf (buf,
		"%n%c %*s %d %lg %s%n", &n1, &cval, &ival, &dval, str, &n2);
	    printf ("nscan=%d: %d '%c' %d %g '%s' %d\n",
		nscan, n1, cval, ival, dval, str, n2);
	    printf (">> \n");
	    fflush (stdout);
	}

	eprintf ("all done\n");
}


onint (code, old_handler)
int	*code;			/* NOTUSED */
int	*old_handler;
{
	write (2, "\7", 1);
	*old_handler = 0;
}


tgettk_()
{
	XCHAR	fname[SZ_FNAME+1];
	char	token[SZ_LINE+1], delim;
	int	maxch = SZ_FNAME;
	FILE	*fp;

	clgstr_ (c_sppstr("fname"), fname, &maxch);
	c_strpak (fname, token, maxch);

	fp = fopen (token, "r");
	if (fp == NULL)
	    c_erract (EA_ERROR);

	while (fscanf (fp, " %[^ \t\n,:()!^&+-*/;|?<>]%c", token,&delim) != EOF)
	    eprintf ("%s\n%c\n", token, delim);

	fclose (fp);
}