hmmer-3.3/easel/esl_huffman.c
/* Given an open <fp> for reading;
 * input text from it and return it as a single string.
 * Optionally return the number of characters in <opt_n>.
 * Convert all \n to spaces.
 */
Given an open  for reading;
input text from it and return it as a single string.
Optionally return the number of characters in .
Convert all \n to spaces.
Given an open for reading ; input text from it and return it as a single string . Optionally return the number of characters in . Convert all \ n to spaces .
static char *
read_text(FILE *fp, int *opt_n)
{
  int   maxlinelen = 4096;
  char *text       = malloc(sizeof(char) * maxlinelen);
  int   n          = 0;
  char *p;
  while (fgets(text+n, maxlinelen-1, fp) != NULL)
    {
      for (p = text+n; *p != '\0'; p++) 
	if (*p == '\n') *p = ' ';
      n   += strlen(text+n);
      text = realloc(text, sizeof(char) * (n+maxlinelen));
    }
  if (opt_n) *opt_n = n;
  return text;
}
static char * read_text ( FILE * fp , int * opt_n ) { int maxlinelen = 4096 ; char * text = malloc ( sizeof ( char ) * maxlinelen ) ; int n = 0 ; char * p ; while ( fgets ( text + n , maxlinelen - 1 , fp ) != NULL ) { for ( p = text + n ; * p != ' \0 ' ; p ++ ) if ( * p == ' \n ' ) * p = ' ' ; n += strlen ( text + n ) ; text = realloc ( text , sizeof ( char ) * ( n + maxlinelen ) ) ; } if ( opt_n ) * opt_n = n ; return text ; }
Given an open <fp> for reading;
 input text from it and return it as a single string.
Given an open <fp > for reading ; input text from it and return it as a single string .