OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkMilestone.h" | 8 #include "SkMilestone.h" |
9 #include "SkPDFMetadata.h" | 9 #include "SkPDFMetadata.h" |
10 #include "SkPDFTypes.h" | 10 #include "SkPDFTypes.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 length = _vscprintf(format, args); | 115 length = _vscprintf(format, args); |
116 va_end(args); | 116 va_end(args); |
117 | 117 |
118 SkString string((size_t)length); | 118 SkString string((size_t)length); |
119 va_start(args, format); | 119 va_start(args, format); |
120 SkDEBUGCODE(int check = ) _vsnprintf_s(string.writable_str(), length + 1, | 120 SkDEBUGCODE(int check = ) _vsnprintf_s(string.writable_str(), length + 1, |
121 _TRUNCATE, format, args); | 121 _TRUNCATE, format, args); |
122 va_end(args); | 122 va_end(args); |
123 SkASSERT(check == length); | 123 SkASSERT(check == length); |
124 SkASSERT(string[length] == '\0'); | 124 SkASSERT(string[length] == '\0'); |
125 return std::move(string); | 125 return string; |
126 #else // C99/C++11 standard vsnprintf | 126 #else // C99/C++11 standard vsnprintf |
127 // TODO: When all compilers support this, remove windows-specific code. | 127 // TODO: When all compilers support this, remove windows-specific code. |
128 va_list args; | 128 va_list args; |
129 va_start(args, format); | 129 va_start(args, format); |
130 char buffer[1024]; | 130 char buffer[1024]; |
131 int length = vsnprintf(buffer, sizeof(buffer), format, args); | 131 int length = vsnprintf(buffer, sizeof(buffer), format, args); |
132 va_end(args); | 132 va_end(args); |
133 if (length < 0) { | 133 if (length < 0) { |
134 return SkString(); | 134 return SkString(); |
135 } | 135 } |
136 if (length < (int)sizeof(buffer)) { | 136 if (length < (int)sizeof(buffer)) { |
137 return SkString(buffer, length); | 137 return SkString(buffer, length); |
138 } | 138 } |
139 SkString string((size_t)length); | 139 SkString string((size_t)length); |
140 va_start(args, format); | 140 va_start(args, format); |
141 SkDEBUGCODE(int check = ) | 141 SkDEBUGCODE(int check = ) |
142 vsnprintf(string.writable_str(), length + 1, format, args); | 142 vsnprintf(string.writable_str(), length + 1, format, args); |
143 va_end(args); | 143 va_end(args); |
144 SkASSERT(check == length); | 144 SkASSERT(check == length); |
145 SkASSERT(string[length] == '\0'); | 145 SkASSERT(string[length] == '\0'); |
146 return std::move(string); | 146 return string; |
147 #endif | 147 #endif |
148 } | 148 } |
149 | 149 |
150 static const SkString get(const SkTArray<SkDocument::Attribute>& info, | 150 static const SkString get(const SkTArray<SkDocument::Attribute>& info, |
151 const char* key) { | 151 const char* key) { |
152 for (const auto& keyValue : info) { | 152 for (const auto& keyValue : info) { |
153 if (keyValue.fKey.equals(key)) { | 153 if (keyValue.fKey.equals(key)) { |
154 return keyValue.fValue; | 154 return keyValue.fValue; |
155 } | 155 } |
156 } | 156 } |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 creator.c_str(), title.c_str(), | 348 creator.c_str(), title.c_str(), |
349 subject.c_str(), author.c_str(), keywords1.c_str(), | 349 subject.c_str(), author.c_str(), keywords1.c_str(), |
350 documentID.c_str(), instanceID.c_str(), keywords2.c_str())); | 350 documentID.c_str(), instanceID.c_str(), keywords2.c_str())); |
351 } | 351 } |
352 | 352 |
353 #endif // SK_PDF_GENERATE_PDFA | 353 #endif // SK_PDF_GENERATE_PDFA |
354 | 354 |
355 #undef SKPDF_STRING | 355 #undef SKPDF_STRING |
356 #undef SKPDF_STRING_IMPL | 356 #undef SKPDF_STRING_IMPL |
357 | 357 |
OLD | NEW |