~drizzle-trunk/drizzle/development

1 by brian
clean slate
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
  strmake(dst,src,length) moves length characters, or until end, of src to
81
  dst and appends a closing NUL to dst.
82
  strmake() returns pointer to closing null;
83
84
  strmov(dst, src) moves all the  characters  of  src  (including  the
85
  closing NUL) to dst, and returns a pointer to the new closing NUL in
86
  dst.	 The similar UNIX routine strcpy returns the old value of dst,
87
  which I have never found useful.  strmov(strmov(dst,a),b) moves a//b
88
  into dst, which seems useful.
89
90
  strnmov(dst,src,length) moves length characters, or until end, of src to
91
  dst and appends a closing NUL to dst if src is shorter than length.
92
  The result is a pointer to the first NUL in dst, or is dst+n if dst was
93
  truncated.
94
95
 strrchr(s, c) returns a pointer to the  last  place  in  s	where  c
96
 occurs,  or  NullS if c does not occur in s. This function is called
97
 rindex in V7 and 4.?bsd systems.
98
 strrchr  looks  for single characters, not for sets or strings.
99
100
 strxmov(dst, src1, ..., srcn, NullS)
101
 moves the concatenation of src1,...,srcn to dst, terminates it
102
 with a NUL character, and returns a pointer to the terminating NUL.
103
 It is just like strmov except that it concatenates multiple sources.
104
 Beware: the last argument should be the null character pointer.
105
 Take VERY great care not to omit it!  Also be careful to use NullS
106
 and NOT to use 0, as on some machines 0 is not the same size as a
107
 character pointer, or not the same bit pattern as NullS.
108
109
 strxnmov(dst, len, src1, ..., srcn, NullS)
110
 moves the first len characters of the concatenation of src1,...,srcn
111
 to dst.  If there aren't that many characters, a NUL character will
112
 be added to the end of dst to terminate it properly.  This gives the
113
 same effect as calling strxcpy(buff, src1, ..., srcn, NullS) with a
114
 large enough buffer, and then calling strnmov(dst, buff, len).
115
 It is just like strnmov except that it concatenates multiple sources.
116
 Beware: the last argument should be the null character pointer.
117
 Take VERY great care not to omit it!  Also be careful to use NullS
118
 and NOT to use 0, as on some machines 0 is not the same size as a
119
 character pointer, or not the same bit pattern as NullS.
120
121
 Note: strxnmov is like strnmov in that it always moves EXACTLY len
122
 characters; dst will be padded on the right with NUL characters as
123
 needed.  strxncpy does the same.  strxncat, like strncat, does NOT.
124
125
126
I mysys:
127
128
 stripp_sp(string str)
129
 Strips end-space from string and returns new length.
130
131
 strlength(const string str)
132
 Return length of string with end-space:s not counted.
133
134
 void caseup _A((string str,uint length));
135
 void casedn _A((string str,uint length));
136
 void caseup_str _A((string str));
137
 void casedn_str _A((string str));
138
 Converts strings or part of string to upper or lower-case.
139
140
 void case_sort _A((string str,uint length));
141
 Converts string to a string with can be compared with strcmp() to
142
 get strings in rigth order.
143
144
 string strcfind(str,search)
145
 find string in another with no case_sensivity
146
147
 my_strcasecmp(s,t)
148
 Compare strings without regarding to case
149
 - For many strings it quicker to forst use case_sort on all strings and
150
   then compare them with strcmp().