~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
266.1.21 by Monty Taylor
Removed references to strmov and strnmov
12
  strncpy() and stpncpy() do.
1 by brian
clean slate
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.
266.1.21 by Monty Taylor
Removed references to strmov and strnmov
54
	stpcpy(stpcpy(stpcpy(stpcpy(s,a),b),c),d)
1 by brian
clean slate
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
  strend(s) returns a character pointer to the NUL which ends s.  That
64
  is,  strend(s)-s  ==  strlen(s). This is useful for adding things at
65
  the end of strings.  It is redundant, because  strchr(s,'\0')  could
66
67
  strfill(dest, len, fill) makes a string of fill-characters. The result
68
  string is of length == len. The des+len character is allways set to NULL.
69
  strfill() returns pointer to dest+len;
70
71
  strfind(src, pat) looks for an instance of pat in src.  pat is not a
72
  regex(3) pattern, it is a literal string which must be matched exactly.
73
  The result is a pointer to the first character of the located instance,
74
  or NullS if pat does not occur in src.
75
76
  strmake(dst,src,length) moves length characters, or until end, of src to
77
  dst and appends a closing NUL to dst.
78
  strmake() returns pointer to closing null;
79
266.1.21 by Monty Taylor
Removed references to strmov and strnmov
80
  stpcpy(dst, src) moves all the  characters  of  src  (including  the
1 by brian
clean slate
81
  closing NUL) to dst, and returns a pointer to the new closing NUL in
82
  dst.	 The similar UNIX routine strcpy returns the old value of dst,
266.1.21 by Monty Taylor
Removed references to strmov and strnmov
83
  which I have never found useful.  stpcpy(stpcpy(dst,a),b) moves a//b
1 by brian
clean slate
84
  into dst, which seems useful.
85
266.1.21 by Monty Taylor
Removed references to strmov and strnmov
86
  stpncpy(dst,src,length) moves length characters, or until end, of src to
1 by brian
clean slate
87
  dst and appends a closing NUL to dst if src is shorter than length.
88
  The result is a pointer to the first NUL in dst, or is dst+n if dst was
89
  truncated.
90
91
 strrchr(s, c) returns a pointer to the  last  place  in  s	where  c
92
 occurs,  or  NullS if c does not occur in s. This function is called
93
 rindex in V7 and 4.?bsd systems.
94
 strrchr  looks  for single characters, not for sets or strings.
95
96
 strxmov(dst, src1, ..., srcn, NullS)
97
 moves the concatenation of src1,...,srcn to dst, terminates it
98
 with a NUL character, and returns a pointer to the terminating NUL.
99
 It is just like strmov except that it concatenates multiple sources.
100
 Beware: the last argument should be the null character pointer.
101
 Take VERY great care not to omit it!  Also be careful to use NullS
102
 and NOT to use 0, as on some machines 0 is not the same size as a
103
 character pointer, or not the same bit pattern as NullS.
104
105
 strxnmov(dst, len, src1, ..., srcn, NullS)
106
 moves the first len characters of the concatenation of src1,...,srcn
107
 to dst.  If there aren't that many characters, a NUL character will
108
 be added to the end of dst to terminate it properly.  This gives the
109
 same effect as calling strxcpy(buff, src1, ..., srcn, NullS) with a
266.1.21 by Monty Taylor
Removed references to strmov and strnmov
110
 large enough buffer, and then calling stpncpy(dst, buff, len).
111
 It is just like stpncpy except that it concatenates multiple sources.
1 by brian
clean slate
112
 Beware: the last argument should be the null character pointer.
113
 Take VERY great care not to omit it!  Also be careful to use NullS
114
 and NOT to use 0, as on some machines 0 is not the same size as a
115
 character pointer, or not the same bit pattern as NullS.
116
266.1.21 by Monty Taylor
Removed references to strmov and strnmov
117
 Note: strxnmov is like stpncpy in that it always moves EXACTLY len
1 by brian
clean slate
118
 characters; dst will be padded on the right with NUL characters as
119
 needed.  strxncpy does the same.  strxncat, like strncat, does NOT.
120
121
122
I mysys:
123
124
 stripp_sp(string str)
125
 Strips end-space from string and returns new length.
126
127
 strlength(const string str)
128
 Return length of string with end-space:s not counted.
129
482 by Brian Aker
Remove uint.
130
 void caseup _A((string str,uint32_t length));
131
 void casedn _A((string str,uint32_t length));
1 by brian
clean slate
132
 void caseup_str _A((string str));
133
 void casedn_str _A((string str));
134
 Converts strings or part of string to upper or lower-case.
135
482 by Brian Aker
Remove uint.
136
 void case_sort _A((string str,uint32_t length));
1 by brian
clean slate
137
 Converts string to a string with can be compared with strcmp() to
138
 get strings in rigth order.
139
140
 string strcfind(str,search)
141
 find string in another with no case_sensivity
142
143
 my_strcasecmp(s,t)
144
 Compare strings without regarding to case
145
 - For many strings it quicker to forst use case_sort on all strings and
146
   then compare them with strcmp().