Mercurial > noffle
comparison src/util.c @ 59:e612b263934f noffle
[svn] Changed some variable types and used some casts to avoid compiler
warnings about signedness. In general, int should be used for parameters
for allowing a signedness assertion in the function.
author | enz |
---|---|
date | Fri, 12 May 2000 17:52:41 +0100 |
parents | 125d79c9e586 |
children | bf8c97460fd7 |
comparison
equal
deleted
inserted
replaced
58:b4e6f7f96135 | 59:e612b263934f |
---|---|
1 /* | 1 /* |
2 util.c | 2 util.c |
3 | 3 |
4 $Id: util.c 60 2000-05-09 22:28:38Z uh1763 $ | 4 $Id: util.c 65 2000-05-12 16:52:41Z enz $ |
5 */ | 5 */ |
6 | 6 |
7 #if HAVE_CONFIG_H | 7 #if HAVE_CONFIG_H |
8 #include <config.h> | 8 #include <config.h> |
9 #endif | 9 #endif |
193 dst[ 0 ] = '\0'; | 193 dst[ 0 ] = '\0'; |
194 strncat( dst, src, MAXCHAR ); | 194 strncat( dst, src, MAXCHAR ); |
195 } | 195 } |
196 | 196 |
197 void | 197 void |
198 Utl_cpyStrN( Str dst, const char *src, size_t n ) | 198 Utl_cpyStrN( Str dst, const char *src, int n ) |
199 { | 199 { |
200 if ( n > MAXCHAR ) | 200 if ( n > MAXCHAR ) |
201 n = MAXCHAR; | 201 n = MAXCHAR; |
202 dst[ 0 ] = '\0'; | 202 dst[ 0 ] = '\0'; |
203 strncat( dst, src, n ); | 203 strncat( dst, src, (size_t)n ); |
204 } | 204 } |
205 | 205 |
206 void | 206 void |
207 Utl_catStr( Str dst, const char *src ) | 207 Utl_catStr( Str dst, const char *src ) |
208 { | 208 { |
209 strncat( dst, src, MAXCHAR - strlen( dst ) ); | 209 strncat( dst, src, MAXCHAR - strlen( dst ) ); |
210 } | 210 } |
211 | 211 |
212 void | 212 void |
213 Utl_catStrN( Str dst, const char *src, size_t n ) | 213 Utl_catStrN( Str dst, const char *src, int n ) |
214 { | 214 { |
215 if ( n > MAXCHAR - strlen( dst ) ) | 215 size_t un; |
216 n = MAXCHAR - strlen( dst ); | 216 |
217 strncat( dst, src, n ); | 217 ASSERT( n >= 0 ); |
218 un = (size_t)n; | |
219 if ( un > MAXCHAR - strlen( dst ) ) | |
220 un = MAXCHAR - strlen( dst ); | |
221 strncat( dst, src, un ); | |
218 } | 222 } |
219 | 223 |
220 void | 224 void |
221 Utl_stamp( Str file ) | 225 Utl_stamp( Str file ) |
222 { | 226 { |