/[pcre]/code/trunk/pcretest.c
ViewVC logotype

Diff of /code/trunk/pcretest.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 288 by ph10, Tue Dec 18 20:11:28 2007 UTC revision 289 by ph10, Sun Dec 23 12:17:20 2007 UTC
# Line 214  for (;;) Line 214  for (;;)
214    if (rlen > 1000)    if (rlen > 1000)
215      {      {
216      int dlen;      int dlen;
217    
218      /* If libreadline support is required, use readline() to read a line if the      /* If libreadline support is required, use readline() to read a line if the
219      input is a terminal. Note that readline() removes the trailing newline, so      input is a terminal. Note that readline() removes the trailing newline, so
220      we must put it back again, to be compatible with fgets(). */      we must put it back again, to be compatible with fgets(). */
221    
222  #ifdef SUPPORT_LIBREADLINE  #ifdef SUPPORT_LIBREADLINE
223      if (isatty(fileno(f)))      if (isatty(fileno(f)))
224        {        {
225        size_t len;        size_t len;
226        char *s = readline(prompt);        char *s = readline(prompt);
227        if (s == NULL) return (here == start)? NULL : start;        if (s == NULL) return (here == start)? NULL : start;
228        len = strlen(s);        len = strlen(s);
229        if (len > 0) add_history(s);        if (len > 0) add_history(s);
230        if (len > rlen - 1) len = rlen - 1;        if (len > rlen - 1) len = rlen - 1;
231        memcpy(here, s, len);        memcpy(here, s, len);
232        here[len] = '\n';        here[len] = '\n';
233        here[len+1] = 0;        here[len+1] = 0;
234        free(s);        free(s);
235        }        }
236      else      else
237  #endif  #endif
238    
239      /* Read the next line by normal means, prompting if the file is stdin. */      /* Read the next line by normal means, prompting if the file is stdin. */
240    
241        {        {
242        if (f == stdin) printf(prompt);        if (f == stdin) printf(prompt);
243        if (fgets((char *)here, rlen,  f) == NULL)        if (fgets((char *)here, rlen,  f) == NULL)
244          return (here == start)? NULL : start;          return (here == start)? NULL : start;
245        }        }
246    
247      dlen = (int)strlen((char *)here);      dlen = (int)strlen((char *)here);
248      if (dlen > 0 && here[dlen - 1] == '\n') return start;      if (dlen > 0 && here[dlen - 1] == '\n') return start;
249      here += dlen;      here += dlen;

Legend:
Removed from v.288  
changed lines
  Added in v.289

webmaster@exim.org
ViewVC Help
Powered by ViewVC 1.1.12