Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* |
michael@0 | 2 | * $Xorg: ifparser.h,v 1.3 2000/08/17 19:41:51 cpqbld Exp $ |
michael@0 | 3 | * |
michael@0 | 4 | * Copyright 1992 Network Computing Devices, Inc. |
michael@0 | 5 | * |
michael@0 | 6 | * Permission to use, copy, modify, and distribute this software and its |
michael@0 | 7 | * documentation for any purpose and without fee is hereby granted, provided |
michael@0 | 8 | * that the above copyright notice appear in all copies and that both that |
michael@0 | 9 | * copyright notice and this permission notice appear in supporting |
michael@0 | 10 | * documentation, and that the name of Network Computing Devices may not be |
michael@0 | 11 | * used in advertising or publicity pertaining to distribution of the software |
michael@0 | 12 | * without specific, written prior permission. Network Computing Devices makes |
michael@0 | 13 | * no representations about the suitability of this software for any purpose. |
michael@0 | 14 | * It is provided ``as is'' without express or implied warranty. |
michael@0 | 15 | * |
michael@0 | 16 | * NETWORK COMPUTING DEVICES DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS |
michael@0 | 17 | * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, |
michael@0 | 18 | * IN NO EVENT SHALL NETWORK COMPUTING DEVICES BE LIABLE FOR ANY SPECIAL, |
michael@0 | 19 | * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM |
michael@0 | 20 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE |
michael@0 | 21 | * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
michael@0 | 22 | * PERFORMANCE OF THIS SOFTWARE. |
michael@0 | 23 | * |
michael@0 | 24 | * Author: Jim Fulton |
michael@0 | 25 | * Network Computing Devices, Inc. |
michael@0 | 26 | * |
michael@0 | 27 | * Simple if statement processor |
michael@0 | 28 | * |
michael@0 | 29 | * This module can be used to evaluate string representations of C language |
michael@0 | 30 | * if constructs. It accepts the following grammar: |
michael@0 | 31 | * |
michael@0 | 32 | * EXPRESSION := VALUE |
michael@0 | 33 | * | VALUE BINOP EXPRESSION |
michael@0 | 34 | * | VALUE '?' EXPRESSION ':' EXPRESSION |
michael@0 | 35 | * |
michael@0 | 36 | * VALUE := '(' EXPRESSION ')' |
michael@0 | 37 | * | '!' VALUE |
michael@0 | 38 | * | '-' VALUE |
michael@0 | 39 | * | '~' VALUE |
michael@0 | 40 | * | 'defined' '(' variable ')' |
michael@0 | 41 | * | variable |
michael@0 | 42 | * | number |
michael@0 | 43 | * |
michael@0 | 44 | * BINOP := '*' | '/' | '%' |
michael@0 | 45 | * | '+' | '-' |
michael@0 | 46 | * | '<<' | '>>' |
michael@0 | 47 | * | '<' | '>' | '<=' | '>=' |
michael@0 | 48 | * | '==' | '!=' |
michael@0 | 49 | * | '&' | '^' | '|' |
michael@0 | 50 | * | '&&' | '||' |
michael@0 | 51 | * |
michael@0 | 52 | * The normal C order of precedence is supported. |
michael@0 | 53 | * |
michael@0 | 54 | * |
michael@0 | 55 | * External Entry Points: |
michael@0 | 56 | * |
michael@0 | 57 | * ParseIfExpression parse a string for #if |
michael@0 | 58 | */ |
michael@0 | 59 | |
michael@0 | 60 | /* $XFree86: xc/config/makedepend/ifparser.h,v 3.5 2001/07/25 15:04:40 dawes Exp $ */ |
michael@0 | 61 | |
michael@0 | 62 | #include <stdio.h> |
michael@0 | 63 | |
michael@0 | 64 | typedef int Bool; |
michael@0 | 65 | #define False 0 |
michael@0 | 66 | #define True 1 |
michael@0 | 67 | |
michael@0 | 68 | typedef struct _if_parser { |
michael@0 | 69 | struct { /* functions */ |
michael@0 | 70 | const char *(*handle_error) (struct _if_parser *, const char *, |
michael@0 | 71 | const char *); |
michael@0 | 72 | long (*eval_variable) (struct _if_parser *, const char *, int); |
michael@0 | 73 | int (*eval_defined) (struct _if_parser *, const char *, int); |
michael@0 | 74 | } funcs; |
michael@0 | 75 | char *data; |
michael@0 | 76 | } IfParser; |
michael@0 | 77 | |
michael@0 | 78 | const char *ParseIfExpression ( |
michael@0 | 79 | IfParser *, |
michael@0 | 80 | const char *, |
michael@0 | 81 | long * |
michael@0 | 82 | ); |
michael@0 | 83 |