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

📄 makeinfo.c

📁 gcc-2.95.3 Linux下最常用的C编译器
💻 C
📖 第 1 页 / 共 5 页
字号:
    suffices to make things work. */#if defined (VMS) || defined (WIN32)#ifdef VMS  while ((n = read (file, result + count, file_size)) > 0)#else /* WIN32 */  while ((n = read (file, result + count, 1)) > 0)#endif /* WIN32 */    count += n;  if (n == -1)#else /* !VMS && !WIN32 */    count = file_size;    if (read (file, result, file_size) != file_size)#endif /* !VMS && !WIN32 */  error_exit:    {      if (result)        free (result);      if (fullpath)        free (fullpath);      if (file != -1)        close (file);      return ((char *) NULL);    }  close (file);  /* Set the globals to the new file. */  input_text = result;  size_of_input_text = count;  input_filename = fullpath;  node_filename = xstrdup (fullpath);  input_text_offset = 0;  line_number = 1;  /* Not strictly necessary.  This magic prevents read_token () from doing     extra unnecessary work each time it is called (that is a lot of times).     SIZE_OF_INPUT_TEXT is one past the actual end of the text. */  input_text[size_of_input_text] = '\n';  /* This, on the other hand, is always necessary.  */  input_text[size_of_input_text+1] = 0;  return (result);}/* Save the state of the current input file. */voidpushfile (){  FSTACK *newstack = (FSTACK *) xmalloc (sizeof (FSTACK));  newstack->filename = input_filename;  newstack->text = input_text;  newstack->size = size_of_input_text;  newstack->offset = input_text_offset;  newstack->line_number = line_number;  newstack->next = filestack;  filestack = newstack;  push_node_filename ();}/* Make the current file globals be what is on top of the file stack. */voidpopfile (){  FSTACK *tos = filestack;  if (!tos)    abort ();                   /* My fault.  I wonder what I did? */#if defined (HAVE_MACROS)  if (macro_expansion_output_stream)    {      maybe_write_itext (input_text, input_text_offset);      forget_itext (input_text);    }#endif /* HAVE_MACROS */  /* Pop the stack. */  filestack = filestack->next;  /* Make sure that commands with braces have been satisfied. */  if (!executing_string && !me_executing_string)    discard_braces ();  /* Get the top of the stack into the globals. */  input_filename = tos->filename;  input_text = tos->text;  size_of_input_text = tos->size;  input_text_offset = tos->offset;  line_number = tos->line_number;  free (tos);  /* Go back to the (now) current node. */  pop_node_filename ();}/* Flush all open files on the file stack. */voidflush_file_stack (){  while (filestack)    {      char *fname = input_filename;      char *text = input_text;      popfile ();      free (fname);      free (text);    }}int node_filename_stack_index = 0;int node_filename_stack_size = 0;char **node_filename_stack = (char **)NULL;voidpush_node_filename (){  if (node_filename_stack_index + 1 > node_filename_stack_size)    node_filename_stack = (char **)xrealloc    (node_filename_stack, (node_filename_stack_size += 10) * sizeof (char *));  node_filename_stack[node_filename_stack_index] = node_filename;  node_filename_stack_index++;}voidpop_node_filename (){  node_filename = node_filename_stack[--node_filename_stack_index];}/* Return just the simple part of the filename; i.e. the   filename without the path information, or extensions.   This conses up a new string. */char *filename_part (filename)     char *filename;{  char *basename;  basename = strrchr (filename, '/');  if (!basename)    basename = filename;  else    basename++;  basename = xstrdup (basename);#if defined (REMOVE_OUTPUT_EXTENSIONS)  /* See if there is an extension to remove.  If so, remove it. */  {    char *temp;    temp = strrchr (basename, '.');    if (temp)      *temp = 0;  }#endif /* REMOVE_OUTPUT_EXTENSIONS */  return (basename);}/* Return the pathname part of filename.  This can be NULL. */char *pathname_part (filename)     char *filename;{  char *expand_filename ();  char *result = (char *) NULL;  register int i;  filename = expand_filename (filename, "");  i = strlen (filename) - 1;  while (i && filename[i] != '/')    i--;  if (filename[i] == '/')    i++;  if (i)    {      result = (char *)xmalloc (1 + i);      strncpy (result, filename, i);      result[i] = 0;    }  free (filename);  return (result);}char *filename_non_directory (name)     char *name;{  register int i;  for (i = strlen (name) - 1; i; i--)    if (name[i] == '/')      return (xstrdup (name + i + 1));  return (xstrdup (name));}/* Return the expansion of FILENAME. */char *expand_filename (filename, input_name)     char *filename, *input_name;{  register int i;  char *full_pathname ();  if (filename)    filename = full_pathname (filename);  else    {      filename = filename_non_directory (input_name);      if (!*filename)        {          free (filename);          filename = xstrdup ("noname.texi");        }      for (i = strlen (filename) - 1; i; i--)        if (filename[i] == '.')          break;      if (!i)        i = strlen (filename);      if (i + 6 > (strlen (filename)))        filename = (char *)xrealloc (filename, i + 6);      strcpy (filename + i, ".info");      return (filename);    }          if (filename[0] == '.' || filename[0] == '/')    return (filename);  if (filename[0] != '/' && input_name[0] == '/')    {      /* Make it so that relative names work. */      char *result;            i = strlen (input_name) - 1;      result = (char *)xmalloc (1 + strlen (input_name) + strlen (filename));      strcpy (result, input_name);      while (result[i] != '/' && i)        i--;      if (result[i] == '/')        i++;      strcpy (&result[i], filename);      free (filename);      return (result);    }  return (filename);}/* Return the full path to FILENAME. */char *full_pathname (filename)     char *filename;{  int initial_character;  char *result;  /* No filename given? */  if (!filename || !(initial_character = *filename))    return (xstrdup (""));    /* Already absolute? */  if ((initial_character == '/') ||      ((strncmp (filename, "./", 2) == 0) ||       (strncmp (filename, "../", 3) == 0)))    return (xstrdup (filename));  if (initial_character != '~')    {      char *localdir;      localdir = (char *)xmalloc (1025);#if defined (HAVE_GETCWD)      if (!getcwd (localdir, 1024))#else  /*  !HAVE_GETCWD */        if (!getwd (localdir))#endif /* !HAVE_GETCWD */          {            fprintf (stderr, _("%s: getwd: %s, %s\n"),                     progname, filename, localdir);            exit (1);          }      strcat (localdir, "/");      strcat (localdir, filename);      result = xstrdup (localdir);      free (localdir);    }  else    {#ifndef WIN32      if (filename[1] == '/')        {          /* Return the concatenation of the environment variable HOME             and the rest of the string. */          char *temp_home;          temp_home = (char *) getenv ("HOME");          result = (char *)xmalloc (strlen (&filename[1])                                    + 1                                    + temp_home ? strlen (temp_home)                                    : 0);          *result = 0;          if (temp_home)            strcpy (result, temp_home);          strcat (result, &filename[1]);        }      else        {          struct passwd *user_entry;          int i, c;          char *username = (char *)xmalloc (257);          for (i = 1; (c = filename[i]); i++)            {              if (c == '/')                break;              else                username[i - 1] = c;            }          if (c)            username[i - 1] = 0;          user_entry = getpwnam (username);          if (!user_entry)            return (xstrdup (filename));          result = (char *)xmalloc (1 + strlen (user_entry->pw_dir)                                    + strlen (&filename[i]));          strcpy (result, user_entry->pw_dir);          strcat (result, &filename[i]);        }    }#endif /* not WIN32 */  return (result);}char *output_name_from_input_name (name)     char *name;{  return (expand_filename ((char *)NULL, name));}/* **************************************************************** *//*                                                                  *//*                      Hacking Tokens and Strings                  *//*                                                                  *//* **************************************************************** *//* Return the next token as a string pointer.  We cons the string. */char *read_token (){  int i, character;  char *result;  /* If the first character to be read is self-delimiting, then that     is the command itself. */  character = curchar ();  if (self_delimiting (character))    {      input_text_offset++;      if (character == '\n')        line_number++;      result = xstrdup (" ");      *result = character;      return (result);    }  for (i = 0; ((input_text_offset != size_of_input_text)               && (character = curchar ())               && command_char (character));       i++, input_text_offset++);  result = (char *)xmalloc (i + 1);  memcpy (result, &input_text[input_text_offset - i], i);  result[i] = 0;  return (result);}/* Return nonzero if CHARACTER is self-delimiting. */intself_delimiting (character)     int character;{  /* @; and @\ are not Texinfo commands, but they are listed here     anyway.  I don't know why.  --karl, 10aug96.  */  return member (character, "~{|}`^\\@?=;:.-,*\'\" !\n\t");}/* Clear whitespace from the front and end of string. */voidcanon_white (string)     char *string;{  int len = strlen (string);  int x;  if (!len)    return;  for (x = 0; x < len; x++)    {      if (!cr_or_whitespace (string[x]))

⌨️ 快捷键说明

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