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

Diff for /src/usr.bin/uniq/uniq.c between version 1.23 and 1.24

version 1.23, 2015/11/02 20:25:42 version 1.24, 2015/12/19 10:21:01
Line 37 
Line 37 
 #include <err.h>  #include <err.h>
 #include <errno.h>  #include <errno.h>
 #include <limits.h>  #include <limits.h>
   #include <locale.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
 #include <unistd.h>  #include <unistd.h>
   #include <wchar.h>
   #include <wctype.h>
   
 #define MAXLINELEN      (8 * 1024)  #define MAXLINELEN      (8 * 1024)
   
Line 61 
Line 64 
         int ch;          int ch;
         char *prevline, *thisline;          char *prevline, *thisline;
   
           setlocale(LC_CTYPE, "");
   
         if (pledge("stdio rpath wpath cpath", NULL) == -1)          if (pledge("stdio rpath wpath cpath", NULL) == -1)
                 err(1, "pledge");                  err(1, "pledge");
   
Line 176 
Line 181 
 char *  char *
 skip(char *str)  skip(char *str)
 {  {
           wchar_t wc;
         int nchars, nfields;          int nchars, nfields;
           int len;
           int field_started;
   
         for (nfields = numfields; nfields && *str; nfields--) {          for (nfields = numfields; nfields && *str; nfields--) {
                 while (isblank((unsigned char)*str))                  /* Skip one field, including preceding blanks. */
                         str++;                  for (field_started = 0; *str != '\0'; str += len) {
                 while (*str && !isblank((unsigned char)*str))                          if ((len = mbtowc(&wc, str, MB_CUR_MAX)) == -1) {
                         str++;                                  (void)mbtowc(NULL, NULL, MB_CUR_MAX);
                                   wc = L'?';
                                   len = 1;
                           }
                           if (iswblank(wc)) {
                                   if (field_started)
                                           break;
                           } else
                                   field_started = 1;
                   }
         }          }
         for (nchars = numchars; nchars-- && *str && *str != '\n'; ++str)  
                 ;          /* Skip some additional characters. */
           for (nchars = numchars; nchars-- && *str != '\0'; str += len)
                   if ((len = mblen(str, MB_CUR_MAX)) == -1)
                           len = 1;
   
         return (str);          return (str);
 }  }
   

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24