indent.c (93440) | indent.c (98771) |
---|---|
1/* 2 * Copyright (c) 1985 Sun Microsystems, Inc. 3 * Copyright (c) 1976 Board of Trustees of the University of Illinois. 4 * Copyright (c) 1980, 1993 5 * The Regents of the University of California. 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 --- 32 unchanged lines hidden (view full) --- 41 The Regents of the University of California. All rights reserved.\n"; 42#endif /* not lint */ 43 44#ifndef lint 45#if 0 46static char sccsid[] = "@(#)indent.c 5.17 (Berkeley) 6/7/93"; 47#endif 48static const char rcsid[] = | 1/* 2 * Copyright (c) 1985 Sun Microsystems, Inc. 3 * Copyright (c) 1976 Board of Trustees of the University of Illinois. 4 * Copyright (c) 1980, 1993 5 * The Regents of the University of California. 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 --- 32 unchanged lines hidden (view full) --- 41 The Regents of the University of California. All rights reserved.\n"; 42#endif /* not lint */ 43 44#ifndef lint 45#if 0 46static char sccsid[] = "@(#)indent.c 5.17 (Berkeley) 6/7/93"; 47#endif 48static const char rcsid[] = |
49 "$FreeBSD: head/usr.bin/indent/indent.c 93440 2002-03-30 17:10:20Z dwmalone $"; | 49 "$FreeBSD: head/usr.bin/indent/indent.c 98771 2002-06-24 17:40:27Z jmallett $"; |
50#endif /* not lint */ 51 52#include <sys/param.h> 53#include <err.h> 54#include <fcntl.h> 55#include <unistd.h> 56#include <stdio.h> 57#include <stdlib.h> --- 18 unchanged lines hidden (view full) --- 76 extern int found_err; /* flag set in diagN() on error */ 77 int dec_ind; /* current indentation for declarations */ 78 int di_stack[20]; /* a stack of structure indentation levels */ 79 int flushed_nl; /* used when buffering up comments to remember 80 * that a newline was passed over */ 81 int force_nl; /* when true, code must be broken */ 82 int hd_type = 0; /* used to store type of stmt for if (...), 83 * for (...), etc */ | 50#endif /* not lint */ 51 52#include <sys/param.h> 53#include <err.h> 54#include <fcntl.h> 55#include <unistd.h> 56#include <stdio.h> 57#include <stdlib.h> --- 18 unchanged lines hidden (view full) --- 76 extern int found_err; /* flag set in diagN() on error */ 77 int dec_ind; /* current indentation for declarations */ 78 int di_stack[20]; /* a stack of structure indentation levels */ 79 int flushed_nl; /* used when buffering up comments to remember 80 * that a newline was passed over */ 81 int force_nl; /* when true, code must be broken */ 82 int hd_type = 0; /* used to store type of stmt for if (...), 83 * for (...), etc */ |
84 register int i; /* local loop counter */ | 84 int i; /* local loop counter */ |
85 int scase; /* set to true when we see a case, so we will 86 * know what to do with the following colon */ 87 int sp_sw; /* when true, we are in the expressin of 88 * if(...), while(...), etc. */ 89 int squest; /* when this is positive, we have seen a ? 90 * without the matching : in a <c>?<s>:<s> 91 * construct */ 92 const char *t_ptr; /* used for copying tokens */ --- 153 unchanged lines hidden (view full) --- 246 if (ps.decl_com_ind <= 0) /* if not specified by user, set this */ 247 ps.decl_com_ind = ps.ljust_decl ? (ps.com_ind <= 10 ? 2 : ps.com_ind - 8) : ps.com_ind; 248 if (continuation_indent == 0) 249 continuation_indent = ps.ind_size; 250 fill_buffer(); /* get first batch of stuff into input buffer */ 251 252 parse(semicolon); 253 { | 85 int scase; /* set to true when we see a case, so we will 86 * know what to do with the following colon */ 87 int sp_sw; /* when true, we are in the expressin of 88 * if(...), while(...), etc. */ 89 int squest; /* when this is positive, we have seen a ? 90 * without the matching : in a <c>?<s>:<s> 91 * construct */ 92 const char *t_ptr; /* used for copying tokens */ --- 153 unchanged lines hidden (view full) --- 246 if (ps.decl_com_ind <= 0) /* if not specified by user, set this */ 247 ps.decl_com_ind = ps.ljust_decl ? (ps.com_ind <= 10 ? 2 : ps.com_ind - 8) : ps.com_ind; 248 if (continuation_indent == 0) 249 continuation_indent = ps.ind_size; 250 fill_buffer(); /* get first batch of stuff into input buffer */ 251 252 parse(semicolon); 253 { |
254 register char *p = buf_ptr; 255 register int col = 1; | 254 char *p = buf_ptr; 255 int col = 1; |
256 257 while (1) { 258 if (*p == ' ') 259 col++; 260 else if (*p == '\t') 261 col = ((col - 1) & ~7) + 9; 262 else 263 break; --- 803 unchanged lines hidden (view full) --- 1067 sc_end = 0; 1068 } 1069 *e_lab = '\0'; /* null terminate line */ 1070 ps.pcase = false; 1071 } 1072 1073 if (strncmp(s_lab, "#if", 3) == 0) { 1074 if (blanklines_around_conditional_compilation) { | 256 257 while (1) { 258 if (*p == ' ') 259 col++; 260 else if (*p == '\t') 261 col = ((col - 1) & ~7) + 9; 262 else 263 break; --- 803 unchanged lines hidden (view full) --- 1067 sc_end = 0; 1068 } 1069 *e_lab = '\0'; /* null terminate line */ 1070 ps.pcase = false; 1071 } 1072 1073 if (strncmp(s_lab, "#if", 3) == 0) { 1074 if (blanklines_around_conditional_compilation) { |
1075 register int c; | 1075 int c; |
1076 prefix_blankline_requested++; 1077 while ((c = getc(input)) == '\n'); 1078 ungetc(c, input); 1079 } 1080 if ((size_t)ifdef_level < sizeof(state_stack)/sizeof(state_stack[0])) { 1081 match_state[ifdef_level].tos = -1; 1082 state_stack[ifdef_level++] = ps; 1083 } --- 95 unchanged lines hidden --- | 1076 prefix_blankline_requested++; 1077 while ((c = getc(input)) == '\n'); 1078 ungetc(c, input); 1079 } 1080 if ((size_t)ifdef_level < sizeof(state_stack)/sizeof(state_stack[0])) { 1081 match_state[ifdef_level].tos = -1; 1082 state_stack[ifdef_level++] = ps; 1083 } --- 95 unchanged lines hidden --- |