lexi.c (116390) | lexi.c (125618) |
---|---|
1/* 2 * Copyright (c) 1985 Sun Microsystems, Inc. 3 * Copyright (c) 1980, 1993 4 * The Regents of the University of California. All rights reserved. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 25 unchanged lines hidden (view full) --- 34 */ 35 36#if 0 37#ifndef lint 38static char sccsid[] = "@(#)lexi.c 8.1 (Berkeley) 6/6/93"; 39#endif /* not lint */ 40#endif 41#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 1985 Sun Microsystems, Inc. 3 * Copyright (c) 1980, 1993 4 * The Regents of the University of California. All rights reserved. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 25 unchanged lines hidden (view full) --- 34 */ 35 36#if 0 37#ifndef lint 38static char sccsid[] = "@(#)lexi.c 8.1 (Berkeley) 6/6/93"; 39#endif /* not lint */ 40#endif 41#include <sys/cdefs.h> |
42__FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 116390 2003-06-15 09:28:17Z charnier $"); | 42__FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 125618 2004-02-09 12:52:15Z bde $"); |
43 44/* 45 * Here we have the token scanner for indent. It scans off one token and puts 46 * it in the global variable "token". It returns a code, indicating the type 47 * of token scanned. 48 */ 49 50#include <err.h> --- 8 unchanged lines hidden (view full) --- 59#define alphanum 1 60#define opchar 3 61 62struct templ { 63 const char *rwd; 64 int rwcode; 65}; 66 | 43 44/* 45 * Here we have the token scanner for indent. It scans off one token and puts 46 * it in the global variable "token". It returns a code, indicating the type 47 * of token scanned. 48 */ 49 50#include <err.h> --- 8 unchanged lines hidden (view full) --- 59#define alphanum 1 60#define opchar 3 61 62struct templ { 63 const char *rwd; 64 int rwcode; 65}; 66 |
67struct templ specials[1000] = | 67struct templ specials[100] = |
68{ 69 {"switch", 1}, 70 {"case", 2}, 71 {"break", 0}, 72 {"struct", 3}, 73 {"union", 3}, 74 {"enum", 3}, 75 {"default", 2}, --- 13 unchanged lines hidden (view full) --- 89 {"goto", 0}, 90 {"return", 0}, 91 {"if", 5}, 92 {"while", 5}, 93 {"for", 5}, 94 {"else", 6}, 95 {"do", 6}, 96 {"sizeof", 7}, | 68{ 69 {"switch", 1}, 70 {"case", 2}, 71 {"break", 0}, 72 {"struct", 3}, 73 {"union", 3}, 74 {"enum", 3}, 75 {"default", 2}, --- 13 unchanged lines hidden (view full) --- 89 {"goto", 0}, 90 {"return", 0}, 91 {"if", 5}, 92 {"while", 5}, 93 {"for", 5}, 94 {"else", 6}, 95 {"do", 6}, 96 {"sizeof", 7}, |
97 {"const", 9}, 98 {"volatile", 9}, | |
99 {0, 0} 100}; 101 102char chartype[128] = 103{ /* this is used to facilitate the decision of 104 * what type (alphanumeric, operator) each 105 * character is */ 106 0, 0, 0, 0, 0, 0, 0, 0, --- 162 unchanged lines hidden (view full) --- 269 switch (p->rwcode) { 270 case 1: /* it is a switch */ 271 return (swstmt); 272 case 2: /* a case or default */ 273 return (casestmt); 274 275 case 3: /* a "struct" */ 276 if (ps.p_l_follow) | 97 {0, 0} 98}; 99 100char chartype[128] = 101{ /* this is used to facilitate the decision of 102 * what type (alphanumeric, operator) each 103 * character is */ 104 0, 0, 0, 0, 0, 0, 0, 0, --- 162 unchanged lines hidden (view full) --- 267 switch (p->rwcode) { 268 case 1: /* it is a switch */ 269 return (swstmt); 270 case 2: /* a case or default */ 271 return (casestmt); 272 273 case 3: /* a "struct" */ 274 if (ps.p_l_follow) |
277 break; /* inside parens: cast */ 278 /* 279 * Next time around, we may want to know that we have had a 280 * 'struct' 281 */ | 275 break; /* inside parens: cast */ |
282 l_struct = true; 283 284 /* | 276 l_struct = true; 277 278 /* |
285 * Fall through to test for a cast, function prototype or 286 * sizeof(). | 279 * Next time around, we will want to know that we have had a 280 * 'struct' |
287 */ 288 case 4: /* one of the declaration keywords */ 289 if (ps.p_l_follow) { 290 ps.cast_mask |= 1 << ps.p_l_follow; | 281 */ 282 case 4: /* one of the declaration keywords */ 283 if (ps.p_l_follow) { 284 ps.cast_mask |= 1 << ps.p_l_follow; |
291 292 /* 293 * Forget that we saw `struct' if we're in a sizeof(). 294 */ 295 if (ps.sizeof_mask) 296 l_struct = false; 297 298 break; /* inside parens: cast, prototype or sizeof() */ | 285 break; /* inside parens: cast */ |
299 } 300 last_code = decl; 301 return (decl); 302 303 case 5: /* if, while, for */ 304 return (sp_paren); 305 306 case 6: /* do, else */ --- 297 unchanged lines hidden --- | 286 } 287 last_code = decl; 288 return (decl); 289 290 case 5: /* if, while, for */ 291 return (sp_paren); 292 293 case 6: /* do, else */ --- 297 unchanged lines hidden --- |