OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 | 135 |
136 void OS::VPrint(const char* format, va_list args) { | 136 void OS::VPrint(const char* format, va_list args) { |
137 #if defined(ANDROID) | 137 #if defined(ANDROID) |
138 LOG_PRI_VA(ANDROID_LOG_INFO, LOG_TAG, format, args); | 138 LOG_PRI_VA(ANDROID_LOG_INFO, LOG_TAG, format, args); |
139 #else | 139 #else |
140 vprintf(format, args); | 140 vprintf(format, args); |
141 #endif | 141 #endif |
142 } | 142 } |
143 | 143 |
144 | 144 |
| 145 void OS::FPrint(FILE* out, const char* format, ...) { |
| 146 va_list args; |
| 147 va_start(args, format); |
| 148 VFPrint(out, format, args); |
| 149 va_end(args); |
| 150 } |
| 151 |
| 152 |
| 153 void OS::VFPrint(FILE* out, const char* format, va_list args) { |
| 154 #if defined(ANDROID) |
| 155 LOG_PRI_VA(ANDROID_LOG_INFO, LOG_TAG, format, args); |
| 156 #else |
| 157 vfprintf(out, format, args); |
| 158 #endif |
| 159 } |
| 160 |
| 161 |
145 void OS::PrintError(const char* format, ...) { | 162 void OS::PrintError(const char* format, ...) { |
146 va_list args; | 163 va_list args; |
147 va_start(args, format); | 164 va_start(args, format); |
148 VPrintError(format, args); | 165 VPrintError(format, args); |
149 va_end(args); | 166 va_end(args); |
150 } | 167 } |
151 | 168 |
152 | 169 |
153 void OS::VPrintError(const char* format, va_list args) { | 170 void OS::VPrintError(const char* format, va_list args) { |
154 #if defined(ANDROID) | 171 #if defined(ANDROID) |
(...skipping 11 matching lines...) Expand all Loading... |
166 va_end(args); | 183 va_end(args); |
167 return result; | 184 return result; |
168 } | 185 } |
169 | 186 |
170 | 187 |
171 int OS::VSNPrintF(Vector<char> str, | 188 int OS::VSNPrintF(Vector<char> str, |
172 const char* format, | 189 const char* format, |
173 va_list args) { | 190 va_list args) { |
174 int n = vsnprintf(str.start(), str.length(), format, args); | 191 int n = vsnprintf(str.start(), str.length(), format, args); |
175 if (n < 0 || n >= str.length()) { | 192 if (n < 0 || n >= str.length()) { |
176 str[str.length() - 1] = '\0'; | 193 // If the length is zero, the assignment fails. |
| 194 if (str.length() > 0) |
| 195 str[str.length() - 1] = '\0'; |
177 return -1; | 196 return -1; |
178 } else { | 197 } else { |
179 return n; | 198 return n; |
180 } | 199 } |
181 } | 200 } |
182 | 201 |
183 | 202 |
184 // ---------------------------------------------------------------------------- | 203 // ---------------------------------------------------------------------------- |
185 // POSIX string support. | 204 // POSIX string support. |
186 // | 205 // |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 return ntohl(value); | 385 return ntohl(value); |
367 } | 386 } |
368 | 387 |
369 | 388 |
370 Socket* OS::CreateSocket() { | 389 Socket* OS::CreateSocket() { |
371 return new POSIXSocket(); | 390 return new POSIXSocket(); |
372 } | 391 } |
373 | 392 |
374 | 393 |
375 } } // namespace v8::internal | 394 } } // namespace v8::internal |
OLD | NEW |