summaryrefslogtreecommitdiff
path: root/unproto/example.c
diff options
context:
space:
mode:
authorRobert de Bath <rdebath@poboxes.com>1997-02-25 20:42:19 +0100
committerLubomir Rintel <lkundrak@v3.sk>2013-10-23 23:38:07 +0200
commit4c36e9a0c125ccfff37aa440dab2cf58c4152fff (patch)
treea5d9c84ba2661029ddb2223dacd50529a361c3d5 /unproto/example.c
parentf8de35da65c5d93bb733073cf40da154bc1c0748 (diff)
parent9696d7b0e1f3a1b0f5fd4a0428eb75afe8ad4ed6 (diff)
downloaddev86-4c36e9a0c125ccfff37aa440dab2cf58c4152fff.tar.gz
Import Dev86src-0.0.11.tar.gzv0.0.11
Diffstat (limited to 'unproto/example.c')
-rw-r--r--unproto/example.c96
1 files changed, 89 insertions, 7 deletions
diff --git a/unproto/example.c b/unproto/example.c
index 003df4a..bf2f838 100644
--- a/unproto/example.c
+++ b/unproto/example.c
@@ -1,9 +1,11 @@
/*
- * @(#) example.c 1.2 91/09/22 21:21:45
+ * @(#) example.c 1.5 93/06/18 22:29:46
*
* Examples of things that can be done with the unproto package
*/
+typedef char *charstar;
+
/*
* New-style argument list with structured argument, one field being pointer
* to function returning pointer to function with function-pointer argument
@@ -17,14 +19,23 @@ x(struct {
return (0);
}
+ /* New-style function-pointer declaration. */
+
+int (*(*bar0) (float)) (int);
+
+ /* Old-style argument list with new-style argument type. */
+
+baz0(bar)
+int (*(*bar) (float)) (int);
+{}
+
/*
- * Old-style argument list with new-style argument type, declaration
+ * New-style argument list with new-style argument type, declaration
* embedded within block. Plus a couple assignments with function calls that
* look like casts.
*/
-foo(bar)
-int (*(*bar) (float)) (int);
+foo(int (*(*bar) (float)) (int))
{
int (*baz) (int) = (int (*) (int)) 0,
y = (y * (*baz) (y)),
@@ -55,9 +66,9 @@ test1()
/* Discriminate declarations from executable statements */
-test2(char *y)
+test2(charstar y)
{
- int foo = 5,atoi(char *);
+ int foo = 5,atoi(charstar);
foo = 5,atoi(y);
}
@@ -103,7 +114,7 @@ test8(x)
{
struct {
int foo;
- } bar(int);
+ } bar(charstar);
}
{
do {
@@ -138,3 +149,74 @@ test11(int *x)
while (*x)
(putchar(*x++));
}
+
+test11a(int *x)
+{
+ for (*x;;)
+ (putchar(*x++));
+}
+
+/* #include directive between stuff that requires lookahead */
+
+test12()
+{
+ char *x = "\xf\0002\002\02\2" /* foo */
+#include "/dev/null"
+ "\abar";
+
+ printf("foo" /* 1 */ "bar" /* 2 */ "baz");
+
+ *x = '\a';
+ *x = '\xff';
+}
+
+int test13(void);
+
+/* line continuations in the middle of tokens */
+
+te\
+st14();
+charstar test15 = "foo\
+bar";
+char test16 = "foo\\
+abar";
+
+/* Array dimensions with unexpanded macros */
+
+test17(charstar foo[bar]){}
+
+int (*(*test18[bar])(charstar))(charstar) = \
+ (int (*(*[bar])(charstar))(charstar)) 0;
+
+/* Function returning pointer to function */
+
+int (*(*test19(long))(int))(double);
+
+/* GCC accepts the following stuff, K&R C does not... */
+
+void test20(int test21(double)) {}
+
+void test22(struct { int foo; } test23(short)) {}
+
+/* Do not blindly rewrite (*name(stuff))(otherstuff) */
+
+void test23()
+{
+ int (*test24(int)) (int),
+ y = (*test24(2)) (3),
+ z = ((*test24(2)) (3));
+}
+
+/* Function returning pointer to function */
+
+int (*(*test25(long foo))(int bar))(double baz){ /* body */ }
+
+int (*(*test26(foo))())()
+long foo;
+{ /* body */ }
+
+#define ARGSTR() struct {int l; char c[1];}
+
+void functie(ARGSTR() *cmdlin, ARGSTR() *c1)
+{
+}