]>
git.saurik.com Git - apple/icu.git/blob - icuSources/tools/genrb/rbutil.c
2 *******************************************************************************
4 * Copyright (C) 1998-2005, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
11 * Modification History:
13 * Date Name Description
14 * 06/10/99 stephen Creation.
15 *******************************************************************************
18 #include "unicode/putil.h"
24 /* go from "/usr/local/include/curses.h" to "/usr/local/include" */
26 get_dirname(char *dirname
,
29 const char *lastSlash
= uprv_strrchr(filename
, U_FILE_SEP_CHAR
) + 1;
31 if(lastSlash
>filename
) {
32 uprv_strncpy(dirname
, filename
, (lastSlash
- filename
));
33 *(dirname
+ (lastSlash
- filename
)) = '\0';
39 /* go from "/usr/local/include/curses.h" to "curses" */
41 get_basename(char *basename
,
44 /* strip off any leading directory portions */
45 const char *lastSlash
= uprv_strrchr(filename
, U_FILE_SEP_CHAR
) + 1;
48 if(lastSlash
>filename
) {
49 uprv_strcpy(basename
, lastSlash
);
51 uprv_strcpy(basename
, filename
);
54 /* strip off any suffix */
55 lastDot
= uprv_strrchr(basename
, '.');
64 itostr(char * buffer
, int32_t i
, uint32_t radix
, int32_t pad
)
73 /* if i is negative make it positive */
79 digit
= (int)(i
% radix
);
80 buffer
[length
++]=(char)(digit
<=9?(0x0030+digit
):(0x0030+digit
+7));
85 buffer
[length
++] = 0x0030;/*zero padding */
88 /* if i is negative add the negative sign */
93 /* null terminate the buffer */
94 if(length
<MAX_DIGITS
){
95 buffer
[length
] = 0x0000;
98 num
= (pad
>=length
) ? pad
:length
;
101 /* Reverses the string */
102 for (j
= 0; j
< (num
/ 2); j
++){
103 temp
= buffer
[(length
-1) - j
];
104 buffer
[(length
-1) - j
] = buffer
[j
];