From 31ce3096fd0c93f37f16bab8a22b3bb86e593d09 Mon Sep 17 00:00:00 2001 From: christos Date: Fri, 18 Apr 2014 01:15:07 +0000 Subject: [PATCH] Add some builtins --- usr.bin/xlint/lint1/main1.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/usr.bin/xlint/lint1/main1.c b/usr.bin/xlint/lint1/main1.c index 3d468553add8..c89539f6ff19 100644 --- a/usr.bin/xlint/lint1/main1.c +++ b/usr.bin/xlint/lint1/main1.c @@ -1,4 +1,4 @@ -/* $NetBSD: main1.c,v 1.21 2013/04/19 17:43:05 christos Exp $ */ +/* $NetBSD: main1.c,v 1.22 2014/04/18 01:15:07 christos Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: main1.c,v 1.21 2013/04/19 17:43:05 christos Exp $"); +__RCSID("$NetBSD: main1.c,v 1.22 2014/04/18 01:15:07 christos Exp $"); #endif #include @@ -128,7 +128,11 @@ sig_atomic_t fpe; static void usage(void); -int main(int, char *[]); +static const char builtins[] = + "int __builtin_isinf(long double);\n" + "int __builtin_isnan(long double);\n" + "int __builtin_copysign(long double, long double);\n" +; /*ARGSUSED*/ static void @@ -203,9 +207,6 @@ main(int argc, char *argv[]) if (argc != 2) usage(); - /* open the input file */ - if ((yyin = fopen(argv[0], "r")) == NULL) - err(1, "cannot open '%s'", argv[0]); /* initialize output */ outopen(argv[1]); @@ -219,6 +220,13 @@ main(int argc, char *argv[]) initscan(); initmtab(); + if ((yyin = fmemopen(__UNCONST(builtins), sizeof(builtins) - 1, "r")) + == NULL) + err(1, "cannot open builtins"); + yyparse(); + /* open the input file */ + if ((yyin = fopen(argv[0], "r")) == NULL) + err(1, "cannot open '%s'", argv[0]); yyparse(); /* Following warnings cannot be suppressed by LINTED */