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

Diff for /src/usr.bin/sort/bwstring.c between version 1.5 and 1.6

version 1.5, 2015/03/20 15:55:22 version 1.6, 2015/04/01 20:58:13
Line 143 
Line 143 
 void  void
 bwsprintf(FILE *f, struct bwstring *bws, const char *prefix, const char *suffix)  bwsprintf(FILE *f, struct bwstring *bws, const char *prefix, const char *suffix)
 {  {
   
         if (sort_mb_cur_max == 1)          if (sort_mb_cur_max == 1)
                 fprintf(f, "%s%s%s", prefix, bws->data.cstr, suffix);                  fprintf(f, "%s%s%s", prefix, bws->data.cstr, suffix);
         else          else
Line 153 
Line 152 
 const void *  const void *
 bwsrawdata(const struct bwstring *bws)  bwsrawdata(const struct bwstring *bws)
 {  {
   
         return &(bws->data);          return &(bws->data);
 }  }
   
 size_t  size_t
 bwsrawlen(const struct bwstring *bws)  bwsrawlen(const struct bwstring *bws)
 {  {
   
         return (sort_mb_cur_max == 1) ? bws->len : SIZEOF_WCHAR_STRING(bws->len);          return (sort_mb_cur_max == 1) ? bws->len : SIZEOF_WCHAR_STRING(bws->len);
 }  }
   
 size_t  size_t
 bws_memsize(const struct bwstring *bws)  bws_memsize(const struct bwstring *bws)
 {  {
   
         return (sort_mb_cur_max == 1) ? (bws->len + 2 + sizeof(struct bwstring)) :          return (sort_mb_cur_max == 1) ? (bws->len + 2 + sizeof(struct bwstring)) :
             (SIZEOF_WCHAR_STRING(bws->len + 1) + sizeof(struct bwstring));              (SIZEOF_WCHAR_STRING(bws->len + 1) + sizeof(struct bwstring));
 }  }
Line 175 
Line 171 
 void  void
 bws_setlen(struct bwstring *bws, size_t newlen)  bws_setlen(struct bwstring *bws, size_t newlen)
 {  {
   
         if (bws && newlen != bws->len && newlen <= bws->len) {          if (bws && newlen != bws->len && newlen <= bws->len) {
                 bws->len = newlen;                  bws->len = newlen;
                 if (sort_mb_cur_max == 1)                  if (sort_mb_cur_max == 1)
Line 235 
Line 230 
 struct bwstring *  struct bwstring *
 bwssbdup(const wchar_t *str, size_t len)  bwssbdup(const wchar_t *str, size_t len)
 {  {
   
         if (str == NULL)          if (str == NULL)
                 return (len == 0) ? bwsalloc(0) : NULL;                  return (len == 0) ? bwsalloc(0) : NULL;
         else {          else {
Line 317 
Line 311 
 void  void
 bwsfree(struct bwstring *s)  bwsfree(struct bwstring *s)
 {  {
   
         sort_free(s);          sort_free(s);
 }  }
   
Line 387 
Line 380 
 bwsnocpy(struct bwstring *dst, const struct bwstring *src, size_t offset,  bwsnocpy(struct bwstring *dst, const struct bwstring *src, size_t offset,
     size_t size)      size_t size)
 {  {
   
         if (offset >= src->len) {          if (offset >= src->len) {
                 dst->data.wstr[0] = 0;                  dst->data.wstr[0] = 0;
                 dst->len = 0;                  dst->len = 0;
Line 420 
Line 412 
 size_t  size_t
 bwsfwrite(struct bwstring *bws, FILE *f, bool zero_ended)  bwsfwrite(struct bwstring *bws, FILE *f, bool zero_ended)
 {  {
   
         if (sort_mb_cur_max == 1) {          if (sort_mb_cur_max == 1) {
                 size_t len = bws->len;                  size_t len = bws->len;
   
Line 525 
Line 516 
                 }                  }
                 rb->fgetwln_z_buffer[*len] = 0;                  rb->fgetwln_z_buffer[*len] = 0;
   
                 if (sort_mb_cur_max == 1)                  if (sort_mb_cur_max == 1) {
                         while (!feof(f)) {                          while (!feof(f)) {
                                 int c;                                  int c;
   
Line 549 
Line 540 
                                 rb->fgetwln_z_buffer[*len] = c;                                  rb->fgetwln_z_buffer[*len] = c;
                                 rb->fgetwln_z_buffer[++(*len)] = 0;                                  rb->fgetwln_z_buffer[++(*len)] = 0;
                         }                          }
                 else                  } else {
                         while (!feof(f)) {                          while (!feof(f)) {
                                 wint_t c = 0;                                  wint_t c = 0;
   
Line 573 
Line 564 
                                 rb->fgetwln_z_buffer[*len] = c;                                  rb->fgetwln_z_buffer[*len] = c;
                                 rb->fgetwln_z_buffer[++(*len)] = 0;                                  rb->fgetwln_z_buffer[++(*len)] = 0;
                         }                          }
                   }
   
 line_read_done:  line_read_done:
                 /* we do not count the last 0 */                  /* we do not count the last 0 */
Line 904 
Line 896 
  * a month name, it returns (number of the month - 1),   * a month name, it returns (number of the month - 1),
  * while if there is no match, it just return -1.   * while if there is no match, it just return -1.
  */   */
   
 int  int
 bws_month_score(const struct bwstring *s0)  bws_month_score(const struct bwstring *s0)
 {  {
   
         if (sort_mb_cur_max == 1) {          if (sort_mb_cur_max == 1) {
                 const char *end, *s;                  const char *end, *s;
                 int i;                  int i;
Line 949 
Line 939 
 struct bwstring *  struct bwstring *
 ignore_leading_blanks(struct bwstring *str)  ignore_leading_blanks(struct bwstring *str)
 {  {
   
         if (sort_mb_cur_max == 1) {          if (sort_mb_cur_max == 1) {
                 unsigned char *dst, *end, *src;                  unsigned char *dst, *end, *src;
   
Line 1109 
Line 1098 
 struct bwstring *  struct bwstring *
 ignore_case(struct bwstring *str)  ignore_case(struct bwstring *str)
 {  {
   
         if (sort_mb_cur_max == 1) {          if (sort_mb_cur_max == 1) {
                 unsigned char *end, *s;                  unsigned char *end, *s;
   
Line 1137 
Line 1125 
 void  void
 bws_disorder_warnx(struct bwstring *s, const char *fn, size_t pos)  bws_disorder_warnx(struct bwstring *s, const char *fn, size_t pos)
 {  {
   
         if (sort_mb_cur_max == 1)          if (sort_mb_cur_max == 1)
                 warnx("%s:%zu: disorder: %s", fn, pos + 1, s->data.cstr);                  warnx("%s:%zu: disorder: %s", fn, pos + 1, s->data.cstr);
         else          else

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6