Switch to unified view

a/src/utils/smallut.cpp b/src/utils/smallut.cpp
1
#ifndef lint
1
#ifndef lint
2
static char rcsid[] = "@(#$Id: smallut.cpp,v 1.34 2008-10-08 16:15:22 dockes Exp $ (C) 2004 J.F.Dockes";
2
static char rcsid[] = "@(#$Id: smallut.cpp,v 1.35 2008-11-19 10:06:49 dockes Exp $ (C) 2004 J.F.Dockes";
3
#endif
3
#endif
4
/*
4
/*
5
 *   This program is free software; you can redistribute it and/or modify
5
 *   This program is free software; you can redistribute it and/or modify
6
 *   it under the terms of the GNU General Public License as published by
6
 *   it under the terms of the GNU General Public License as published by
7
 *   the Free Software Foundation; either version 2 of the License, or
7
 *   the Free Software Foundation; either version 2 of the License, or
...
...
493
    } else {
493
    } else {
494
        out += *it;
494
        out += *it;
495
    }
495
    }
496
    }
496
    }
497
    return true;
497
    return true;
498
}
499
500
// Convert byte count into unit (KB/MB...) appropriate for display
501
string displayableBytes(long size)
502
{
503
    char sizebuf[30];
504
    const char * unit = " B ";
505
506
    if (size > 1024 && size < 1024*1024) {
507
  unit = " KB ";
508
  size /= 1024;
509
    } else if (size  >= 1024*1204) {
510
  unit = " MB ";
511
  size /= (1024*1024);
512
    }
513
    sprintf(sizebuf, "%ld%s", size, unit);
514
    return string(sizebuf);
515
}
516
517
string breakIntoLines(const string& in, unsigned int ll, 
518
            unsigned int maxlines)
519
{
520
    string query = in;
521
    string oq;
522
    unsigned int nlines = 0;
523
    while (query.length() > 0) {
524
  string ss = query.substr(0, ll);
525
  if (ss.length() == ll) {
526
      string::size_type pos = ss.find_last_of(" ");
527
      if (pos == string::npos) {
528
      pos = query.find_first_of(" ");
529
      if (pos != string::npos)
530
          ss = query.substr(0, pos+1);
531
      else 
532
          ss = query;
533
      } else {
534
      ss = ss.substr(0, pos+1);
535
      }
536
  }
537
  // This cant happen, but anyway. Be very sure to avoid an infinite loop
538
  if (ss.length() == 0) {
539
      oq = query;
540
      break;
541
  }
542
  oq += ss + "\n";
543
  if (nlines++ >= maxlines) {
544
      oq += " ... \n";
545
      break;
546
  }
547
  query= query.substr(ss.length());
548
    }
549
    return oq;
498
}
550
}
499
551
500
////////////////////
552
////////////////////
501
// Internal redefinition of system time interface to help with dependancies
553
// Internal redefinition of system time interface to help with dependancies
502
struct m_timespec {
554
struct m_timespec {