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

📄 makedoc.c

📁 mutt-1.5.12 源代码。linux 下邮件接受的工具。
💻 C
📖 第 1 页 / 共 2 页
字号:
}static void print_confline (const char *varname, int type, const char *val, FILE *out){  if (type == DT_SYN) return;    switch (OutputFormat)  {    /* configuration file */    case F_CONF:    {      if (type == DT_STR || type == DT_RX || type == DT_ADDR || type == DT_PATH)      {	fprintf (out, "\n# set %s=\"", varname);	conf_print_strval (val, out);	fputs ("\"", out);      }      else if (type != DT_SYN)	fprintf (out, "\n# set %s=%s", varname, val);            fprintf (out, "\n#\n# Name: %s", varname);      fprintf (out, "\n# Type: %s", type2human (type));      if (type == DT_STR || type == DT_RX || type == DT_ADDR || type == DT_PATH)      {	fputs ("\n# Default: \"", out);	conf_print_strval (val, out);	fputs ("\"", out);      }      else	fprintf (out, "\n# Default: %s", val);      fputs ("\n# ", out);      break;    }    /* manual page */    case F_MAN:    {      fprintf (out, "\n.TP\n.B %s\n", varname);      fputs (".nf\n", out);      fprintf (out, "Type: %s\n", type2human (type));      if (type == DT_STR || type == DT_RX || type == DT_ADDR || type == DT_PATH)      {	fputs ("Default: \\(lq", out);	man_print_strval (val, out);	fputs ("\\(rq\n", out);      }      else	fprintf (out, "Default: %s\n", val);      fputs (".fi", out);      break;    }        /* SGML based manual */    case F_SGML:    {      fputs ("\n<sect2 id=\"", out);      sgml_id_fputs(varname, out);      fputs ("\">\n<title>", out);      sgml_fputs (varname, out);      fprintf (out, "</title>\n<literallayout>Type: %s", type2human (type));            if (type == DT_STR || type == DT_RX || type == DT_ADDR || type == DT_PATH)      {	fputs ("\nDefault: &quot;", out);	sgml_print_strval (val, out);	fputs ("&quot;</literallayout>\n", out);      }      else	fprintf (out, "\nDefault: %s</literallayout>\n", val);      break;    }    /* make gcc happy */    default:      break;  }}/** ** Documentation line parser ** ** The following code parses specially formatted documentation  ** comments in init.h. ** ** The format is very remotely inspired by nroff. Most important, it's ** easy to parse and convert, and it was easy to generate from the SGML  ** source of mutt's original manual. ** ** - \fI switches to italics ** - \fB switches to boldface ** - \fP switches to normal display ** - .dl on a line starts a definition list (name taken taken from HTML). ** - .dt starts a term in a definition list. ** - .dd starts a definition in a definition list. ** - .de on a line finishes a definition list. ** - .ts on a line starts a "tscreen" environment (name taken from SGML). ** - .te on a line finishes this environment. ** - .pp on a line starts a paragraph. ** - \$word will be converted to a reference to word, where appropriate. **   Note that \$$word is possible as well. ** - '. ' in the beginning of a line expands to two space characters. **   This is used to protect indentations in tables. **//* close eventually-open environments. */static int fd_recurse = 0;static int flush_doc (int docstat, FILE *out){  if (docstat & D_INIT)    return D_INIT;  if (fd_recurse++)  {    fprintf (stderr, "%s: Internal error, recursion in flush_doc()!\n", Progname);    exit (1);  }  if (docstat & (D_PA))    docstat = print_it (SP_END_PAR, NULL, out, docstat);  if (docstat & (D_TAB))    docstat = print_it (SP_END_TAB, NULL, out, docstat);  if (docstat & (D_DL))    docstat = print_it (SP_END_DL, NULL, out, docstat);  if (docstat & (D_EM | D_BF))    docstat = print_it (SP_END_FT, NULL, out, docstat);  docstat = print_it (SP_END_SECT, NULL, out, docstat);  docstat = print_it (SP_NEWLINE, NULL, out, 0);  fd_recurse--;  return D_INIT;}/* print something. */static int print_it (int special, char *str, FILE *out, int docstat){  int onl = docstat & (D_NL|D_NP);    docstat &= ~(D_NL|D_NP|D_INIT);  switch (OutputFormat)  {    /* configuration file */    case F_CONF:    {      switch (special)      {	static int Continuation = 0;	case SP_END_FT: docstat &= ~(D_EM|D_BF); break;	case SP_START_BF: docstat |= D_BF; break;	case SP_START_EM: docstat |= D_EM; break;	case SP_NEWLINE: 	{	  if (onl)	    docstat |= onl;	  else	  {	    fputs ("\n# ", out);	    docstat |= D_NL;	  }	  if (docstat & D_DL)	    ++ Continuation;	  break;	}	case SP_NEWPAR:	{	  if (onl & D_NP)	  {	    docstat |= onl;	    break;	  }	  if (!(onl & D_NL))	    fputs ("\n# ", out);	  fputs ("\n# ", out);	  docstat |= D_NP;	  break;	}	case SP_START_TAB: 	{	  if (!onl) 	    fputs ("\n# ", out);	  docstat |= D_TAB;	  break;	}	case SP_END_TAB:	{	  docstat &= ~D_TAB;	  docstat |= D_NL;	  break;	}	case SP_START_DL:	{	  docstat |= D_DL;	  break;	}	case SP_DT:	{	  Continuation = 0;	  docstat |= D_DT;	  break;	}	case SP_DD:	{	  Continuation = 0;	  break;	}	case SP_END_DL:	{	  Continuation = 0;	  docstat &= ~D_DL;	  break;	}	case SP_STR:	{	  if (Continuation)	  {	    Continuation = 0;	    fputs ("        ", out);	  }	  fputs (str, out);	  if (docstat & D_DT)	  { 	    int i;	    for (i = strlen (str) ; i < 8 ; i++)	      putc (' ', out);	    docstat &= ~D_DT;	    docstat |= D_NL;	  }	  break;	}      }      break;    }    /* manual page */    case F_MAN:    {      switch (special)      {	case SP_END_FT: 	{	  fputs ("\\fP", out);	  docstat &= ~(D_EM|D_BF);	  break;	}	case SP_START_BF: 	{	  fputs ("\\fB", out);	  docstat |= D_BF;	  docstat &= ~D_EM;	  break;	}	case SP_START_EM:	{	  fputs ("\\fI", out);	  docstat |= D_EM;	  docstat &= ~D_BF;	  break;	}	case SP_NEWLINE:	{	  if (onl)	    docstat |= onl;	  else	  {	    fputc ('\n', out);	    docstat |= D_NL;	  }	  break;	}	case SP_NEWPAR:	{	  if (onl & D_NP)	  {	    docstat |= onl;	    break;	  }	  if (!(onl & D_NL))	    fputc ('\n', out);	  fputs (".IP\n", out);	  docstat |= D_NP;	  break;	}	case SP_START_TAB:	{	  fputs ("\n.IP\n.DS\n.sp\n.ft CR\n.nf\n", out);	  docstat |= D_TAB | D_NL;	  break;	}	case SP_END_TAB:	{	  fputs ("\n.fi\n.ec\n.ft P\n.sp\n", out);	  docstat &= ~D_TAB;	  docstat |= D_NL;	  break;	}	case SP_START_DL:	{	  fputs ("\n.RS", out);	  docstat |= D_DL;	  break;	}	case SP_DT:	{	  fputs ("\n.IP ", out);	  break;	}	case SP_DD:	{	  fputs ("\n", out);	  break;	}	case SP_END_DL:	{	  fputs ("\n.RE", out);	  docstat &= ~D_DL;	  break;	}	case SP_STR:	{	  while (*str)	  {	    for (; *str; str++)	    {	      if (*str == '"')		fputs ("\\(rq", out);	      else if (*str == '\\')		fputs ("\\\\", out);	      else if (!strncmp (str, "``", 2))	      {		fputs ("\\(lq", out);		str++;	      }	      else if (!strncmp (str, "''", 2))	      {		fputs ("\\(rq", out);		str++;	      }	      else		fputc (*str, out);	    }	  }	  break;	}      }      break;    }    /* SGML based manual */    case F_SGML:    {      switch (special)      {	case SP_END_FT: 	{	  if (docstat & D_EM) fputs ("</emphasis>", out);	  if (docstat & D_BF) fputs ("</emphasis>", out);	  docstat &= ~(D_EM|D_BF);	  break;	}	case SP_START_BF: 	{	  fputs ("<emphasis role=\"bold\">", out);	  docstat |= D_BF;	  docstat &= ~D_EM;	  break;	}	case SP_START_EM:	{	  fputs ("<emphasis>", out);	  docstat |= D_EM;	  docstat &= ~D_BF;	  break;	}	case SP_NEWLINE:	{	  if (onl)	    docstat |= onl;	  else	  {	    fputc ('\n', out);	    docstat |= D_NL;	  }	  break;	}	case SP_NEWPAR:	{	  if (onl & D_NP)	  {	    docstat |= onl;	    break;	  }	  if (!(onl & D_NL))	    fputc ('\n', out);	  if (docstat & D_PA)	    fputs("</para>\n", out);	  fputs ("<para>\n", out);	  docstat |= D_NP;	  docstat |= D_PA;	  break;	}        case SP_END_PAR:        {	  fputs ("</para>\n", out);	  docstat &= ~D_PA;	  break;        }	case SP_START_TAB:	{	  fputs ("\n<screen>\n", out);	  docstat |= D_TAB | D_NL;	  break;	}	case SP_END_TAB:	{	  fputs ("\n</screen>", out);	  docstat &= ~D_TAB;	  docstat |= D_NL;	  break;	}	case SP_START_DL:	{	  fputs ("\n<variablelist>\n", out);	  docstat |= D_DL;	  break;	}	case SP_DT:	{	  fputs ("<varlistentry><term>", out);	  break;	}	case SP_DD:	{	  docstat |= D_DD;	  fputs ("</term>\n<listitem><para>", out);	  break;	}        case SP_END_DD:        {	  docstat &= ~D_DD;	  fputs ("</para></listitem></varlistentry>\n", out);	  break;        }	case SP_END_DL:	{	  fputs ("</para></listitem></varlistentry></variablelist>\n", out);	  docstat &= ~(D_DD|D_DL);	  break;	}        case SP_END_SECT:        {	  fputs ("</sect2>", out);	  break;        }	case SP_STR:	{	  if (docstat & D_TAB)	    fputs (str, out);	  else	    sgml_fputs (str, out);	  break;	}      }      break;    }    /* make gcc happy (unreached) */    default:      break;  }  return docstat;}void print_ref (FILE *out, int output_dollar, const char *ref){  switch (OutputFormat)  {  case F_CONF:  case F_MAN:    if (output_dollar)      putc ('$', out);    fputs (ref, out);    break;  case F_SGML:    fputs ("<link linkend=\"", out);    sgml_id_fputs (ref, out);    fputs ("\">", out);    if (output_dollar)      fputs ("&dollar;", out);    sgml_fputs (ref, out);    fputs ("</link>", out);    break;  default:    break;  }}static int commit_buff (char *buff, char **d, FILE *out, int docstat){  if (*d > buff)  {    **d = '\0';    docstat = print_it (SP_STR, buff, out, docstat);    *d = buff;  }  return docstat;}static int handle_docline (char *l, FILE *out, int docstat){  char buff[BUFFSIZE];  char *s, *d;  l = skip_ws (l);  if (Debug)    fprintf (stderr, "%s: handle_docline `%s'\n", Progname, l);    if (!strncmp (l, ".pp", 3))    return print_it (SP_NEWPAR, NULL, out, docstat);  else if (!strncmp (l, ".ts", 3))    return print_it (SP_START_TAB, NULL, out, docstat);  else if (!strncmp (l, ".te", 3))    return print_it (SP_END_TAB, NULL, out, docstat);  else if (!strncmp (l, ".dl", 3))    return print_it (SP_START_DL, NULL, out, docstat);  else if (!strncmp (l, ".de", 3))    return print_it (SP_END_DL, NULL, out, docstat);  else if (!strncmp (l, ". ", 2))    *l = ' ';  for (s = l, d = buff; *s; s++)  {    if (!strncmp (s, "\\(as", 4))    {      *d++ = '*';      s += 3;    }    else if (!strncmp (s, "\\(rs", 4))    {      *d++ = '\\';      s += 3;    }    else if (!strncmp (s, "\\fI", 3))    {      docstat = commit_buff (buff, &d, out, docstat);      docstat = print_it (SP_START_EM, NULL, out, docstat);      s += 2;    }    else if (!strncmp (s, "\\fB", 3))    {      docstat = commit_buff (buff, &d, out, docstat);      docstat = print_it (SP_START_BF, NULL, out, docstat);      s += 2;    }    else if (!strncmp (s, "\\fP", 3))    {      docstat = commit_buff (buff, &d, out, docstat);      docstat = print_it (SP_END_FT, NULL, out, docstat);      s += 2;    }    else if (!strncmp (s, ".dt", 3))    {      if (docstat & D_DD)      {	docstat = commit_buff (buff, &d, out, docstat);	docstat = print_it (SP_END_DD, NULL, out, docstat);      }      docstat = commit_buff (buff, &d, out, docstat);      docstat = print_it (SP_DT, NULL, out, docstat);      s += 3;    }    else if (!strncmp (s, ".dd", 3))    {      docstat = commit_buff (buff, &d, out, docstat);      docstat = print_it (SP_DD, NULL, out, docstat);      s += 3;    }    else if (*s == '$')    {      int output_dollar = 0;      char *ref;      char save;      ++s;      if (*s == '$')      {	output_dollar = 1;	++s;      }      if (*s == '$')      {	*d++ = '$';      }      else      {	ref = s;	while (isalnum ((unsigned char) *s) || *s == '-' || *s == '_')	  ++s;	docstat = commit_buff (buff, &d, out, docstat);	save = *s;	*s = 0;	print_ref (out, output_dollar, ref);	*s = save;	--s;      }    }    else      *d++ = *s;  }  docstat = commit_buff (buff, &d, out, docstat);  return print_it (SP_NEWLINE, NULL, out, docstat);}

⌨️ 快捷键说明

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