[BACK]Return to search.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mg

Diff for /src/usr.bin/mg/search.c between version 1.10 and 1.11

version 1.10, 2003/05/20 03:08:55 version 1.11, 2004/07/22 01:25:25
Line 462 
Line 462 
         int     s;          int     s;
         int     rcnt = 0;               /* replacements made so far     */          int     rcnt = 0;               /* replacements made so far     */
         int     plen;                   /* length of found string       */          int     plen;                   /* length of found string       */
         char    news[NPAT];             /* replacement string           */          char    news[NPAT], *rep;       /* replacement string           */
   
 #ifndef NO_MACRO  #ifndef NO_MACRO
         if (macrodef) {          if (macrodef) {
Line 473 
Line 473 
   
         if ((s = readpattern("Query replace")) != TRUE)          if ((s = readpattern("Query replace")) != TRUE)
                 return (s);                  return (s);
         if ((s = ereply("Query replace %s with: ", news, NPAT, pat)) == ABORT)          if ((rep = ereply("Query replace %s with: ", news, NPAT, pat)) == NULL)
                 return (s);                  return ABORT;
         if (s == FALSE)          else if (rep[0] == '\0')
                 news[0] = '\0';                  news[0] = '\0';
         ewprintf("Query replacing %s with %s:", pat, news);          ewprintf("Query replacing %s with %s:", pat, news);
         plen = strlen(pat);          plen = strlen(pat);
Line 664 
Line 664 
 int  int
 readpattern(char *prompt)  readpattern(char *prompt)
 {  {
         int     s;          char    tpat[NPAT], *rep;
         char    tpat[NPAT];          int retval;
   
         if (tpat[0] == '\0')          if (tpat[0] == '\0')
                 s = ereply("%s: ", tpat, NPAT, prompt);                  rep = ereply("%s: ", tpat, NPAT, prompt);
         else          else
                 s = ereply("%s: (default %s) ", tpat, NPAT, prompt, pat);                  rep = ereply("%s: (default %s) ", tpat, NPAT, prompt, pat);
   
         /* specified */          /* specified */
         if (s == TRUE)          if (rep != NULL && *rep != '\0') {
                 (void) strlcpy(pat, tpat, sizeof pat);                  (void) strlcpy(pat, tpat, sizeof pat);
         /* CR, but old one */                  retval = TRUE;
         else if (s == FALSE && pat[0] != 0)          } else if (*rep == '\0' && pat[0] != '\0') {
                 s = TRUE;                  retval = TRUE;
         return s;          } else
                   retval = FALSE;
           return retval;
 }  }
   

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11