diff options
author | Stephen Hines <srhines@google.com> | 2013-03-27 17:13:14 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-03-27 17:13:14 -0700 |
commit | 075b42c9b9747aafd4496169b872d4ef15d765a8 (patch) | |
tree | 8c0eedd92fef49822d841c1ae7b93faf6e6b167b | |
parent | 648dacdbc4933066d5f9e27e2089df0920dcb549 (diff) | |
parent | 9d234b6c83c9d6baab71433fdecab6bfde34a956 (diff) | |
download | android_frameworks_compile_slang-075b42c9b9747aafd4496169b872d4ef15d765a8.tar.gz android_frameworks_compile_slang-075b42c9b9747aafd4496169b872d4ef15d765a8.tar.bz2 android_frameworks_compile_slang-075b42c9b9747aafd4496169b872d4ef15d765a8.zip |
am 9d234b6c: Fix filename-escaping for Windows paths.
* commit '9d234b6c83c9d6baab71433fdecab6bfde34a956':
Fix filename-escaping for Windows paths.
-rw-r--r-- | slang_rs_reflection.cpp | 16 | ||||
-rw-r--r-- | tests/P_str_escape/stderr.txt.expect | 0 | ||||
-rw-r--r-- | tests/P_str_escape/stdout.txt.expect | 1 | ||||
-rw-r--r-- | tests/P_str_escape/str\\escape.rs | 2 |
4 files changed, 17 insertions, 2 deletions
diff --git a/slang_rs_reflection.cpp b/slang_rs_reflection.cpp index c13689e..772545b 100644 --- a/slang_rs_reflection.cpp +++ b/slang_rs_reflection.cpp @@ -263,6 +263,17 @@ static std::string GetBuiltinElementConstruct(const RSExportType *ET) { return ""; } +// Replace all instances of "\" with "\\" in a single string to prevent +// formatting errors due to unicode. +static std::string SanitizeString(std::string s) { + size_t p = 0; + while ( ( p = s.find('\\', p)) != std::string::npos) { + s.replace(p, 1, "\\\\"); + p+=2; + } + return s; +} + /********************** Methods to generate script class **********************/ bool RSReflection::genScriptClass(Context &C, @@ -2096,7 +2107,7 @@ bool RSReflection::reflect(const std::string &OutputPathBase, /************************** RSReflection::Context **************************/ const char *const RSReflection::Context::ApacheLicenseNote = "/*\n" - " * Copyright (C) 2011-2012 The Android Open Source Project\n" + " * Copyright (C) 2011-2013 The Android Open Source Project\n" " *\n" " * Licensed under the Apache License, Version 2.0 (the \"License\");\n" " * you may not use this file except in compliance with the License.\n" @@ -2163,7 +2174,8 @@ bool RSReflection::Context::startClass(AccessModifier AM, // Notice of generated file out() << "/*" << std::endl; out() << " * This file is auto-generated. DO NOT MODIFY!" << std::endl; - out() << " * The source Renderscript file: " << mInputRSFile << std::endl; + out() << " * The source Renderscript file: " + << SanitizeString(mInputRSFile) << std::endl; out() << " */" << std::endl; // Package diff --git a/tests/P_str_escape/stderr.txt.expect b/tests/P_str_escape/stderr.txt.expect new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/P_str_escape/stderr.txt.expect diff --git a/tests/P_str_escape/stdout.txt.expect b/tests/P_str_escape/stdout.txt.expect new file mode 100644 index 0000000..fd90090 --- /dev/null +++ b/tests/P_str_escape/stdout.txt.expect @@ -0,0 +1 @@ +Generating ScriptC_strescape.java ... diff --git a/tests/P_str_escape/str\\escape.rs b/tests/P_str_escape/str\\escape.rs new file mode 100644 index 0000000..b2072d5 --- /dev/null +++ b/tests/P_str_escape/str\\escape.rs @@ -0,0 +1,2 @@ +#pragma version(1) +#pragma rs java_package_name(foo) |