]>
git.saurik.com Git - apple/icu.git/blob - icuSources/tools/genrb/rbutil.c
2 *******************************************************************************
4 * Copyright (C) 1998-2008, 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 * 02/07/08 Spieth Correct XLIFF generation on EBCDIC platform
17 *******************************************************************************
20 #include "unicode/putil.h"
26 /* go from "/usr/local/include/curses.h" to "/usr/local/include" */
28 get_dirname(char *dirname
,
31 const char *lastSlash
= uprv_strrchr(filename
, U_FILE_SEP_CHAR
) + 1;
33 if(lastSlash
>filename
) {
34 uprv_strncpy(dirname
, filename
, (lastSlash
- filename
));
35 *(dirname
+ (lastSlash
- filename
)) = '\0';
41 /* go from "/usr/local/include/curses.h" to "curses" */
43 get_basename(char *basename
,
46 /* strip off any leading directory portions */
47 const char *lastSlash
= uprv_strrchr(filename
, U_FILE_SEP_CHAR
) + 1;
50 if(lastSlash
>filename
) {
51 uprv_strcpy(basename
, lastSlash
);
53 uprv_strcpy(basename
, filename
);
56 /* strip off any suffix */
57 lastDot
= uprv_strrchr(basename
, '.');
66 itostr(char * buffer
, int32_t i
, uint32_t radix
, int32_t pad
)
68 const char digits
[16] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'};
76 /* if i is negative make it positive */
82 digit
= (int)(i
% radix
);
83 buffer
[length
++]= digits
[digit
];
88 buffer
[length
++] = '0';/*zero padding */
91 /* if i is negative add the negative sign */
96 /* null terminate the buffer */
97 if(length
<MAX_DIGITS
){
98 buffer
[length
] = 0x0000;
101 num
= (pad
>=length
) ? pad
:length
;
104 /* Reverses the string */
105 for (j
= 0; j
< (num
/ 2); j
++){
106 temp
= buffer
[(length
-1) - j
];
107 buffer
[(length
-1) - j
] = buffer
[j
];