~linuxjedi/drizzle/trunk-bug-667053

« back to all changes in this revision

Viewing changes to strings/string.doc

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Speciella anv�ndbara nya string-rutiner:
 
2
 
 
3
  bcmp(s1, s2, len) returns 0 if the "len" bytes starting at "s1" are
 
4
  identical to the "len" bytes starting at "s2", non-zero if they are
 
5
  different.
 
6
 
 
7
  bfill(dst, len, fill) moves "len" fill characters to "dst".
 
8
  Thus to set a buffer to 80 spaces, do bfill(buff, 80, ' ').
 
9
 
 
10
  bmove(dst, src, len) moves exactly "len" bytes from the source "src"
 
11
  to the destination "dst".  It does not check for NUL characters as
 
12
  strncpy() and strnmov() do.
 
13
 
 
14
  bmove_upp(dst, src, len) moves exactly "len" bytes from the source
 
15
 "src-len" to the destination "dst-len" counting downwards.
 
16
 
 
17
  bzero(dst, len) moves "len" 0 bytes to "dst".
 
18
  Thus to clear a disc buffer to 0s do bzero(buffer, BUFSIZ).
 
19
 
 
20
  int2str(dst, radix, val)
 
21
  converts the (long) integer "val" to character form and moves it to
 
22
  the destination string "dst" followed by a terminating NUL.  The
 
23
  result is normally a pointer to this NUL character, but if the radix
 
24
  is dud the result will be NullS and nothing will be changed.
 
25
  If radix is -2..-36, val is taken to be SIGNED.
 
26
  If radix is  2.. 36, val is taken to be UNSIGNED.
 
27
  That is, val is signed if and only if radix is.  You will normally
 
28
  use radix -10 only through itoa and ltoa, for radix 2, 8, or 16
 
29
  unsigned is what you generally want.
 
30
 
 
31
  m_ctype.h
 
32
  A better inplementation of the UNIX ctype(3) library.
 
33
  Notes:   global.h should be included before ctype.h
 
34
    - Se efter i filen \c\local\include\m_ctype.h
 
35
    - Anv�nds ist�llet f�r ctype.h f�r att klara internationella karakterer.
 
36
 
 
37
  m_string.h
 
38
  Anv�nd inst�llet f�r string.h f�r att supporta snabbare str�ngfunktioner.
 
39
 
 
40
  strintstr(src, from, pat) looks for an instance of pat in src
 
41
  backwards from pos from.  pat is not a regex(3) pattern, it is a literal
 
42
  string which must be matched exactly.
 
43
  The result 0 if the pattern was not found else it is the start char of
 
44
  the pattern counted from the begining of the string.
 
45
 
 
46
  strappend(dest, len, fill) appends fill-characters to a string so that
 
47
  the result length == len. If the string is longer than len it's
 
48
  trunked. The des+len character is allways set to NULL.
 
49
 
 
50
  strcat(s, t) concatenates t on the end of s.  There  had  better  be
 
51
  enough  room  in  the  space s points to; strcat has no way to tell.
 
52
  Note that strcat has to search for the end of s, so if you are doing
 
53
  a lot of concatenating it may be better to use strmov, e.g.
 
54
        strmov(strmov(strmov(strmov(s,a),b),c),d)
 
55
    rather than
 
56
        strcat(strcat(strcat(strcpy(s,a),b),c),d).
 
57
    strcat returns the old value of s.
 
58
        - Anv�nd inte strcat, anv�nd strmov (se ovan).
 
59
 
 
60
  strcend(s, c) returns a pointer to the  first  place  in  s   where  c
 
61
  occurs,  or a pointer to the end-null of s if c does not occur in s.
 
62
 
 
63
  strcont(str, set) if str contanies any character in the string set.
 
64
  The result is the position of the first found character in str, or NullS
 
65
  if there isn't anything found.
 
66
 
 
67
  strend(s) returns a character pointer to the NUL which ends s.  That
 
68
  is,  strend(s)-s  ==  strlen(s). This is useful for adding things at
 
69
  the end of strings.  It is redundant, because  strchr(s,'\0')  could
 
70
 
 
71
  strfill(dest, len, fill) makes a string of fill-characters. The result
 
72
  string is of length == len. The des+len character is allways set to NULL.
 
73
  strfill() returns pointer to dest+len;
 
74
 
 
75
  strfind(src, pat) looks for an instance of pat in src.  pat is not a
 
76
  regex(3) pattern, it is a literal string which must be matched exactly.
 
77
  The result is a pointer to the first character of the located instance,
 
78
  or NullS if pat does not occur in src.
 
79
 
 
80
  strinstr(src, pat) looks for an instance of pat in src.  pat is not a
 
81
  regex(3) pattern, it is a literal string which must be matched exactly.
 
82
  The result 0 if the pattern was not found else it is the start char of
 
83
  the pattern counted from the begining of the string.
 
84
 
 
85
  strmake(dst,src,length) moves length characters, or until end, of src to
 
86
  dst and appends a closing NUL to dst.
 
87
  strmake() returns pointer to closing null;
 
88
 
 
89
  strmov(dst, src) moves all the  characters  of  src  (including  the
 
90
  closing NUL) to dst, and returns a pointer to the new closing NUL in
 
91
  dst.   The similar UNIX routine strcpy returns the old value of dst,
 
92
  which I have never found useful.  strmov(strmov(dst,a),b) moves a//b
 
93
  into dst, which seems useful.
 
94
 
 
95
  strnmov(dst,src,length) moves length characters, or until end, of src to
 
96
  dst and appends a closing NUL to dst if src is shorter than length.
 
97
  The result is a pointer to the first NUL in dst, or is dst+n if dst was
 
98
  truncated.
 
99
 
 
100
 strrchr(s, c) returns a pointer to the  last  place  in  s     where  c
 
101
 occurs,  or  NullS if c does not occur in s. This function is called
 
102
 rindex in V7 and 4.?bsd systems.
 
103
 strrchr  looks  for single characters, not for sets or strings.
 
104
 
 
105
 strxmov(dst, src1, ..., srcn, NullS)
 
106
 moves the concatenation of src1,...,srcn to dst, terminates it
 
107
 with a NUL character, and returns a pointer to the terminating NUL.
 
108
 It is just like strmov except that it concatenates multiple sources.
 
109
 Beware: the last argument should be the null character pointer.
 
110
 Take VERY great care not to omit it!  Also be careful to use NullS
 
111
 and NOT to use 0, as on some machines 0 is not the same size as a
 
112
 character pointer, or not the same bit pattern as NullS.
 
113
 
 
114
 strxnmov(dst, len, src1, ..., srcn, NullS)
 
115
 moves the first len characters of the concatenation of src1,...,srcn
 
116
 to dst.  If there aren't that many characters, a NUL character will
 
117
 be added to the end of dst to terminate it properly.  This gives the
 
118
 same effect as calling strxcpy(buff, src1, ..., srcn, NullS) with a
 
119
 large enough buffer, and then calling strnmov(dst, buff, len).
 
120
 It is just like strnmov except that it concatenates multiple sources.
 
121
 Beware: the last argument should be the null character pointer.
 
122
 Take VERY great care not to omit it!  Also be careful to use NullS
 
123
 and NOT to use 0, as on some machines 0 is not the same size as a
 
124
 character pointer, or not the same bit pattern as NullS.
 
125
 
 
126
 Note: strxnmov is like strnmov in that it always moves EXACTLY len
 
127
 characters; dst will be padded on the right with NUL characters as
 
128
 needed.  strxncpy does the same.  strxncat, like strncat, does NOT.
 
129
 
 
130
 
 
131
I mysys:
 
132
 
 
133
 stripp_sp(string str)
 
134
 Strips end-space from string and returns new length.
 
135
 
 
136
 strlength(const string str)
 
137
 Return length of string with end-space:s not counted.
 
138
 
 
139
 void caseup _A((string str,uint length));
 
140
 void casedn _A((string str,uint length));
 
141
 void caseup_str _A((string str));
 
142
 void casedn_str _A((string str));
 
143
 Converts strings or part of string to upper or lower-case.
 
144
 
 
145
 void case_sort _A((string str,uint length));
 
146
 Converts string to a string with can be compared with strcmp() to
 
147
 get strings in rigth order.
 
148
 
 
149
 string strcfind(str,search)
 
150
 find string in another with no case_sensivity
 
151
 
 
152
 my_strcasecmp(s,t)
 
153
 Compare strings without regarding to case
 
154
 - For many strings it quicker to forst use case_sort on all strings and
 
155
   then compare them with strcmp().