| OLD | NEW |
| 1 /****************************************************************************** | 1 /****************************************************************************** |
| 2 * Copyright (C) 2008-2014, International Business Machines | 2 * Copyright (C) 2008-2015, International Business Machines |
| 3 * Corporation and others. All Rights Reserved. | 3 * Corporation and others. All Rights Reserved. |
| 4 ******************************************************************************* | 4 ******************************************************************************* |
| 5 */ | 5 */ |
| 6 #include "unicode/utypes.h" | 6 #include "unicode/utypes.h" |
| 7 #include "unicode/localpointer.h" |
| 7 #include "unicode/putil.h" | 8 #include "unicode/putil.h" |
| 8 #include "cstring.h" | 9 #include "cstring.h" |
| 9 #include "toolutil.h" | 10 #include "toolutil.h" |
| 10 #include "uoptions.h" | 11 #include "uoptions.h" |
| 11 #include "uparse.h" | 12 #include "uparse.h" |
| 12 #include "package.h" | 13 #include "package.h" |
| 13 #include "pkg_icu.h" | 14 #include "pkg_icu.h" |
| 14 | 15 |
| 15 #include <stdio.h> | 16 #include <stdio.h> |
| 16 #include <stdlib.h> | 17 #include <stdlib.h> |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 } else { | 143 } else { |
| 143 listPkg->addItem(listname); | 144 listPkg->addItem(listname); |
| 144 } | 145 } |
| 145 } | 146 } |
| 146 | 147 |
| 147 return listPkg; | 148 return listPkg; |
| 148 } | 149 } |
| 149 | 150 |
| 150 U_CAPI int U_EXPORT2 | 151 U_CAPI int U_EXPORT2 |
| 151 writePackageDatFile(const char *outFilename, const char *outComment, const char
*sourcePath, const char *addList, Package *pkg, char outType) { | 152 writePackageDatFile(const char *outFilename, const char *outComment, const char
*sourcePath, const char *addList, Package *pkg, char outType) { |
| 152 Package *addListPkg = NULL; | 153 LocalPointer<Package> ownedPkg; |
| 153 UBool pkgDelete = FALSE; | 154 LocalPointer<Package> addListPkg; |
| 154 | 155 |
| 155 if (pkg == NULL) { | 156 if (pkg == NULL) { |
| 156 pkg = new Package; | 157 ownedPkg.adoptInstead(new Package); |
| 157 if(pkg == NULL) { | 158 if(ownedPkg.isNull()) { |
| 158 fprintf(stderr, "icupkg: not enough memory\n"); | 159 fprintf(stderr, "icupkg: not enough memory\n"); |
| 159 return U_MEMORY_ALLOCATION_ERROR; | 160 return U_MEMORY_ALLOCATION_ERROR; |
| 160 } | 161 } |
| 162 pkg = ownedPkg.getAlias(); |
| 161 | 163 |
| 162 addListPkg = readList(sourcePath, addList, TRUE, NULL); | 164 addListPkg.adoptInstead(readList(sourcePath, addList, TRUE, NULL)); |
| 163 if(addListPkg != NULL) { | 165 if(addListPkg.isValid()) { |
| 164 pkg->addItems(*addListPkg); | 166 pkg->addItems(*addListPkg); |
| 165 } else { | 167 } else { |
| 166 return U_ILLEGAL_ARGUMENT_ERROR; | 168 return U_ILLEGAL_ARGUMENT_ERROR; |
| 167 } | 169 } |
| 168 | |
| 169 pkgDelete = TRUE; | |
| 170 } | 170 } |
| 171 | 171 |
| 172 pkg->writePackage(outFilename, outType, outComment); | 172 pkg->writePackage(outFilename, outType, outComment); |
| 173 | |
| 174 if (pkgDelete) { | |
| 175 delete pkg; | |
| 176 delete addListPkg; | |
| 177 } | |
| 178 | |
| 179 return 0; | 173 return 0; |
| 180 } | 174 } |
| 181 | |
| OLD | NEW |