⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 io.c

📁 GNU 系统开发优化 C 语言程序的应用程序
💻 C
📖 第 1 页 / 共 2 页
字号:
	putc (EOL, output);    inhibit_newline:      ++out_lines;      if (parser_state_tos->just_saw_decl == 1	  && blanklines_after_declarations)	{	  prefix_blankline_requested = 1;	  parser_state_tos->just_saw_decl = 0;	}      else	prefix_blankline_requested = postfix_blankline_requested;      postfix_blankline_requested = 0;    }  /* if we are in the middle of a declaration, remember that fact     for proper comment indentation */  parser_state_tos->decl_on_line = parser_state_tos->in_decl;  /* next line should be indented if we have not completed this     stmt and if we are not in the middle of a declaration */  parser_state_tos->ind_stmt = (parser_state_tos->in_stmt				& ~parser_state_tos->in_decl);  parser_state_tos->dumped_decl_indent = 0;  *(e_lab  = s_lab) = '\0';	/* reset buffers */  *(e_code = s_code) = '\0';  *(e_com  = s_com) = '\0';  parser_state_tos->ind_level = parser_state_tos->i_l_follow;  parser_state_tos->paren_level = parser_state_tos->p_l_follow;  if (parser_state_tos->paren_level > 0)    paren_target      = -parser_state_tos->paren_indents[parser_state_tos->paren_level - 1];  else    paren_target = 0;  not_first_line = 1;  return;}/* Return the column in which we should place the code about to be output. */INLINE intcompute_code_target (){  register target_col = parser_state_tos->ind_level + 1;  register w, t;  if (! parser_state_tos->paren_level)    {      if (parser_state_tos->ind_stmt)	target_col += continuation_indent;      return target_col;    }  if (!lineup_to_parens)    return target_col + (continuation_indent * parser_state_tos->paren_level);  t = paren_target;  if ((w = count_columns (t, s_code) - max_col) > 0      && count_columns (target_col, s_code) <= max_col)    {      t -= w + 1;      if (t > target_col)	target_col = t;    }  else    target_col = t;  return target_col;}INLINE intcompute_label_target (){  return  parser_state_tos->pcase ? case_ind + 1  : *s_lab == '#' ? 1  : parser_state_tos->ind_level - LABEL_OFFSET + 1;}/* VMS defines it's own read routine, `vms_read' */#ifndef SYS_READ#define SYS_READ read#endif/* Read file FILENAME into a `fileptr' structure, and return a pointer to   that structure. */static struct file_buffer fileptr;struct file_buffer *read_file (filename)     char *filename;{  int fd, size;  struct stat file_stats;  int namelen = strlen (filename);  fd = open (filename, O_RDONLY, 0777);  if (fd < 0)    sys_error (filename);  if (fstat (fd, &file_stats) < 0)    sys_error (filename);  if (fileptr.data != 0)    free (fileptr.data);  fileptr.size = file_stats.st_size;  fileptr.data = (char *) xmalloc (file_stats.st_size + 1);  size = SYS_READ (fd, fileptr.data, fileptr.size);  if (size < 0)    sys_error (filename);  if (close (fd) < 0)    sys_error (filename);  /* Apparently, the DOS stores files using CR-LF for newlines, but     then the DOS `read' changes them into '\n'.  Thus, the size of the     file on disc is larger than what is read into memory.  Thanks, Bill. */  if (size != fileptr.size)    fileptr.size = size;  fileptr.name = (char *) xmalloc (namelen + 1);  memcpy (fileptr.name, filename, namelen);  fileptr.name[namelen] = '\0';  fileptr.data[fileptr.size] = '\0';  return &fileptr;}/* This should come from stdio.h and be some system-optimal number */#ifndef BUFSIZ#define BUFSIZ 1024#endif/* Suck the standard input into a file_buffer structure, and   return a pointer to that structure. */struct file_buffer stdinptr;struct file_buffer *read_stdin (){  unsigned int size = 15 * BUFSIZ;  int ch;  register char *p;  if (stdinptr.data != 0)    free (stdinptr.data);  stdinptr.data = (char *) xmalloc (size + 1);  stdinptr.size = 0;  p = stdinptr.data;  do    {      while (stdinptr.size < size)	{	  ch = getc (stdin);	  if (ch == EOF)	    break;	  *p++ = ch;	  stdinptr.size++;	}      if (ch != EOF)	{	  size += (2 * BUFSIZ);	  stdinptr.data = xrealloc (stdinptr.data, size);	  p = stdinptr.data + stdinptr.size;	}    }  while (ch != EOF);  stdinptr.name = "Standard Input";  stdinptr.data[stdinptr.size] = '\0';  return &stdinptr;}/* Advance `buf_ptr' so that it points to the next line of input.   If the next input line contains an indent control comment turning   off formatting (a comment, C or C++, beginning with *INDENT-OFF*),   then simply print out input lines without formatting until we find   a corresponding comment containing *INDENT-0N* which re-enables   formatting.   Note that if this is a C comment we do not look for the closing   delimiter.  Note also that older version of this program also   skipped lines containing *INDENT** which represented errors   generated by indent in some previous formatting.  This version does   not recognize such lines. */INLINE voidfill_buffer (){  register char *p;  int inhibit_formatting = 0;  /* indent() may be saving the text between "if (...)" and the following     statement.  To do so, it uses another buffer (`save_com').  Switch     back to the previous buffer here. */  if (bp_save != 0)    {      buf_ptr = bp_save;      buf_end = be_save;      bp_save = be_save = 0;      /* only return if there is really something in this buffer */      if (buf_ptr < buf_end)	return;    }  /* If formatting gets turned off, then just loop here outputting lines     until formatting is re-enabled. */  do    {      /* Advance buf_ptr past last line, and return if EOF. */      cur_line = buf_ptr = in_prog_pos;      if (*buf_ptr == '\0')	{	  had_eof = true;	  return;	}      /* Examine the beginning of the line for an indent control         comment. */      p = buf_ptr;      while (*p == ' ' || *p == TAB)	p++;      if (*p == '/' && (*(p + 1) == '*' || *(p + 1) == '/'))	{	  p += 2;	  while (*p == ' ' || *p == TAB)	    p++;	  if (! inhibit_formatting)	    {	      if (! strncmp (p, "*INDENT-OFF*", 12))		{		  if (s_com != e_com || s_lab != e_lab || s_code != e_code)		    dump_line ();		  inhibit_formatting = 1;		}	    }	  else	    {	      if (! strncmp (p, "*INDENT-ON*", 11))		{		  p += 11;		  /* Set inhibit_formatting to 2 so that we will		     still toss out this whole line, but drop out		     of the loop afterwards. */		  inhibit_formatting = 2;		  n_real_blanklines = 0;		  postfix_blankline_requested = 0;		  prefix_blankline_requested = 0;		  suppress_blanklines = 1;		}	    }	}      /* Now procede through the rest of the line */      while (*p != '\0' && *p != EOL)	p++;      buf_end = in_prog_pos = p + 1;      if (inhibit_formatting)	{	  p = buf_ptr;	  while (p < buf_end)	    putc (*p++, output);	  if (inhibit_formatting == 2)	    {	      inhibit_formatting = 0;	      continue;	    }	}    }  while (inhibit_formatting);}/* Fill the output line with whitespace up to TARGET_COLUMN, given that   the line is currently in column CURRENT_COLUMN.  Returns the ending   column. */INLINE intpad_output (current_column, target_column)  register int current_column;  register int target_column;{  if (troff)    {      fprintf (output, "\\h'|%dp'", (int) ((target_column - 1) * 7));      return 0;    }  if (current_column >= target_column)    return current_column;  if (tabsize > 1)    {      register int offset;      offset = tabsize - (current_column - 1) % tabsize;      while (current_column + offset <= target_column)	{	  putc (TAB, output);	  current_column += offset;	  offset = tabsize;	}    }  while (current_column < target_column)    {      putc (' ', output);      current_column++;    }  return current_column;}/* Nonzero if we have found an error (not a warning).  */int found_err;/* Signal an error.  LEVEL is nonzero if it is an error (as opposed to a   warning.  MSG is a printf-style format string.  Additional arguments are   additional arguments for printf.  *//* VARARGS2 */diag (level, msg, a, b)     int level;     unsigned int a, b;     char *msg;{  if (level)    found_err = 1;  fprintf (stderr, "indent:%s:%d: %s: ", in_name, (int) line_no,	   level == 0 ? "Warning" : "Error");  if (msg)    fprintf (stderr, msg, a, b);  fprintf (stderr, "\n");}writefdef (f, nm)     register struct fstate *f;     unsigned int nm;{  fprintf (output, ".ds f%c %s\n.nr s%c %d\n",	   (int) nm, f->font, nm, (int) f->size);}/* Write characters starting at S to change the font from OF to NF.  Return a   pointer to the character after the last character written. For troff mode   only.  */char *chfont (of, nf, s)     register struct fstate *of, *nf;     char *s;{  if (of->font[0] != nf->font[0]      || of->font[1] != nf->font[1])    {      *s++ = '\\';      *s++ = 'f';      if (nf->font[1])	{	  *s++ = '(';	  *s++ = nf->font[0];	  *s++ = nf->font[1];	}      else	*s++ = nf->font[0];    }  if (nf->size != of->size)    {      *s++ = '\\';      *s++ = 's';      if (nf->size < of->size)	{	  *s++ = '-';	  *s++ = '0' + of->size - nf->size;	}      else	{	  *s++ = '+';	  *s++ = '0' + nf->size - of->size;	}    }  return s;}voidparsefont (f, s0)     register struct fstate *f;     char *s0;{  register char *s = s0;  int sizedelta = 0;  int i;  f->size = 0;  f->allcaps = 1;  for (i = 0; i < 4; i++)    f->font[i] = 0;  while (*s)    {      if (isdigit (*s))	f->size = f->size * 10 + *s - '0';      else if (isupper (*s))	if (f->font[0])	  f->font[1] = *s;	else	  f->font[0] = *s;      else if (*s == 'c')	f->allcaps = 1;      else if (*s == '+')	sizedelta++;      else if (*s == '-')	sizedelta--;      else	{	  fprintf (stderr, "indent: bad font specification: %s\n", s0);	  exit (1);	}      s++;    }  if (f->font[0] == 0)    f->font[0] = 'R';  if (bodyf.size == 0)    bodyf.size = 11;  if (f->size == 0)    f->size = bodyf.size + sizedelta;  else if (sizedelta > 0)    f->size += bodyf.size;  else    f->size = bodyf.size - f->size;}#ifdef DEBUGvoiddump_debug_line (){  fprintf (output, "\n*** Debug output marker line ***\n");}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -