File: assign.cc

package info (click to toggle)
nullmailer 1.00RC7-22
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,192 kB
  • ctags: 695
  • sloc: cpp: 4,375; sh: 519; makefile: 249; perl: 184; ansic: 10
file content (55 lines) | stat: -rw-r--r-- 850 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "mystring.h"
#include "trace.h"
#include <ctype.h>
#include <string.h>

void mystring::dupnil()
{
  trace("");
  rep = &nil;
  rep->attach();
}

void mystring::assign(const char* in)
{
  if(in)
    assign(in, strlen(in));
  else {
    mystringrep* tmp = rep;
    dupnil();
    tmp->detach();
  }
}

void mystring::assign(const char* in, size_t len)
{
  trace("in='" << in << "'");
  if(in != rep->buf) {
    mystringrep* tmp = rep;
    dup(in, len);
    tmp->detach();
  }
}

void mystring::dup(const char* in, size_t len)
{
  trace("in='" << in << "'");
  rep = mystringrep::dup(in, len);
  rep->attach();
}

void mystring::dup(const char* in)
{
  if(in)
    dup(in, strlen(in));
  else
    dupnil();
}

void mystring::operator=(const mystringjoin& in)
{
  mystringrep* tmp = rep;
  rep = in.traverse();
  rep->attach();
  tmp->detach();
}