Browse Source

Fixed missing U in some string literals.

David Piuva 10 months ago
parent
commit
3680656487

+ 4 - 4
Source/DFPSR/api/fileAPI.cpp

@@ -125,7 +125,7 @@ Buffer file_loadBuffer(const ReadableString& filename, bool mustExist) {
 		return buffer;
 	} else {
 		if (mustExist) {
-			throwError(U"Failed to load ", modifiedFilename, ".\n");
+			throwError(U"Failed to load ", modifiedFilename, U".\n");
 		}
 		// If the file cound not be found and opened, an empty buffer is returned
 		return Buffer();
@@ -146,7 +146,7 @@ bool file_saveBuffer(const ReadableString& filename, Buffer buffer, bool mustWor
 			fclose(file);
 		} else {
 			if (mustWork) {
-				throwError("Failed to save ", modifiedFilename, ".\n");
+				throwError(U"Failed to save ", modifiedFilename, U".\n");
 			}
 			return false;
 		}
@@ -406,7 +406,7 @@ String file_followSymbolicLink(const ReadableString &path, bool mustExist) {
 			return fromNativeString(resultBuffer);
 		}
 	#endif
-	if (mustExist) { throwError(U"The symbolic link ", path, " could not be found!\n"); }
+	if (mustExist) { throwError(U"The symbolic link ", path, U" could not be found!\n"); }
 	return U"?";
 }
 
@@ -429,7 +429,7 @@ String file_getApplicationFolder(bool allowFallback) {
 		} else if (allowFallback) {
 			return file_getCurrentPath();
 		} else {
-			throwError("file_getApplicationFolder is not implemented for the current system!\n");
+			throwError(U"file_getApplicationFolder is not implemented for the current system!\n");
 			return U"";
 		}
 	#endif

+ 9 - 9
Source/DFPSR/api/stringAPI.cpp

@@ -210,7 +210,7 @@ String dsr::string_unmangleQuote(const ReadableString& mangledText) {
 	intptr_t lastQuote = string_findLast(mangledText, '\"');
 	String result;
 	if (firstQuote == -1 || lastQuote == -1 || firstQuote == lastQuote) {
-		throwError(U"Cannot unmangle using string_unmangleQuote without beginning and ending with quote signs!\n", mangledText, "\n");
+		throwError(U"Cannot unmangle using string_unmangleQuote without beginning and ending with quote signs!\n", mangledText, U"\n");
 	} else {
 		for (intptr_t i = firstQuote + 1; i < lastQuote; i++) {
 			DsrChar c = mangledText[i];
@@ -241,19 +241,19 @@ String dsr::string_unmangleQuote(const ReadableString& mangledText) {
 			} else {
 				// Detect bad input
 				if (c == U'\"') { // Double quote
-					 throwError(U"Unmangled double quote sign detected in string_unmangleQuote!\n", mangledText, "\n");
+					 throwError(U"Unmangled double quote sign detected in string_unmangleQuote!\n", mangledText, U"\n");
 				} else if (c == U'\a') { // Audible bell
-					 throwError(U"Unmangled audible bell detected in string_unmangleQuote!\n", mangledText, "\n");
+					 throwError(U"Unmangled audible bell detected in string_unmangleQuote!\n", mangledText, U"\n");
 				} else if (c == U'\b') { // Backspace
-					 throwError(U"Unmangled backspace detected in string_unmangleQuote!\n", mangledText, "\n");
+					 throwError(U"Unmangled backspace detected in string_unmangleQuote!\n", mangledText, U"\n");
 				} else if (c == U'\f') { // Form feed
-					 throwError(U"Unmangled form feed detected in string_unmangleQuote!\n", mangledText, "\n");
+					 throwError(U"Unmangled form feed detected in string_unmangleQuote!\n", mangledText, U"\n");
 				} else if (c == U'\n') { // Line feed
-					 throwError(U"Unmangled line feed detected in string_unmangleQuote!\n", mangledText, "\n");
+					 throwError(U"Unmangled line feed detected in string_unmangleQuote!\n", mangledText, U"\n");
 				} else if (c == U'\r') { // Carriage return
-					 throwError(U"Unmangled carriage return detected in string_unmangleQuote!\n", mangledText, "\n");
+					 throwError(U"Unmangled carriage return detected in string_unmangleQuote!\n", mangledText, U"\n");
 				} else if (c == U'\0') { // Null terminator
-					 throwError(U"Unmangled null terminator detected in string_unmangleQuote!\n", mangledText, "\n");
+					 throwError(U"Unmangled null terminator detected in string_unmangleQuote!\n", mangledText, U"\n");
 				} else {
 					string_appendChar(result, c);
 				}
@@ -512,7 +512,7 @@ static void feedStringFromRawData(const UTF32WriterFunction &receiver, const uin
 	} else if (encoding == CharacterEncoding::BOM_UTF16LE) {
 		feedStringFromFileBuffer_UTF16<true, true>(receiver, buffer);
 	} else {
-		throwError("Unhandled encoding in feedStringFromRawData!\n");
+		throwError(U"Unhandled encoding in feedStringFromRawData!\n");
 	}
 }
 

+ 1 - 1
Source/DFPSR/base/virtualStack.cpp

@@ -137,7 +137,7 @@ namespace dsr {
 			// Tell the allocation that we are using it.
 			heap_increaseUseCount(newAllocation.data);
 			if (newAllocation.data == nullptr) {
-				throwError(U"Failed to allocate ", regionSize, U" bytes of heap memory for expanding the virtual stack when trying to allocate ", paddedSize, " bytes!\n");
+				throwError(U"Failed to allocate ", regionSize, U" bytes of heap memory for expanding the virtual stack when trying to allocate ", paddedSize, U" bytes!\n");
 				return UnsafeAllocation(nullptr, nullptr);
 			} else {
 				// Keep the new allocation.

+ 2 - 2
Source/DFPSR/collection/collections.cpp

@@ -28,13 +28,13 @@ namespace dsr {
 
 void impl_nonZeroLengthCheck(int64_t length, const char* property) {
 	if (length <= 0) {
-		throwError(property, " may not be zero!\n");
+		throwError(property, U" may not be zero!\n");
 	}
 }
 
 void impl_baseZeroBoundCheck(int64_t index, int64_t length, const char* property) {
 	if (index < 0 || index >= length) {
-		throwError(property, " ", index, " is out of bound 0..", (length - 1), "!\n");
+		throwError(property, U" ", index, U" is out of bound 0..", (length - 1), U"!\n");
 	}
 }
 

+ 8 - 8
Source/soundManagers/AlsaSound.cpp

@@ -39,7 +39,7 @@ bool sound_streamToSpeakers(int channels, int sampleRate, std::function<bool(Saf
 	int errorCode;
 	if ((errorCode = snd_pcm_open(&pcm, "default", SND_PCM_STREAM_PLAYBACK, 0)) < 0) {
 		terminateSound();
-		sendWarning("Cannot open sound device. (", snd_strerror(errorCode), ")\n");
+		sendWarning(U"Cannot open sound device. (", snd_strerror(errorCode), U")\n");
 		return false;
 	}
 	snd_pcm_hw_params_t *hardwareParameters;
@@ -47,33 +47,33 @@ bool sound_streamToSpeakers(int channels, int sampleRate, std::function<bool(Saf
 	snd_pcm_hw_params_any(pcm, hardwareParameters);
 	if ((errorCode = snd_pcm_hw_params_set_access(pcm, hardwareParameters, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
 		terminateSound();
-		sendWarning("Failed to select interleaved sound. (", snd_strerror(errorCode), ")\n");
+		sendWarning(U"Failed to select interleaved sound. (", snd_strerror(errorCode), U")\n");
 		return false;
 	}
 	if ((errorCode = snd_pcm_hw_params_set_format(pcm, hardwareParameters, SND_PCM_FORMAT_S16_LE)) < 0) {
 		terminateSound();
-		sendWarning("Failed to select sound format. (", snd_strerror(errorCode), ")\n");
+		sendWarning(U"Failed to select sound format. (", snd_strerror(errorCode), U")\n");
 		return false;
 	}
 	if ((errorCode = snd_pcm_hw_params_set_channels(pcm, hardwareParameters, channels)) < 0) {
 		terminateSound();
-		sendWarning("Failed to select channel count. (", snd_strerror(errorCode), ")\n");
+		sendWarning(U"Failed to select channel count. (", snd_strerror(errorCode), U")\n");
 		return false;
 	}
 	if ((errorCode = snd_pcm_hw_params_set_buffer_size(pcm, hardwareParameters, 2048)) < 0) {
 		terminateSound();
-		sendWarning("Failed to select buffer size. (", snd_strerror(errorCode), ")\n");
+		sendWarning(U"Failed to select buffer size. (", snd_strerror(errorCode), U")\n");
 		return false;
 	}
 	uint rate = sampleRate;
 	if ((errorCode = snd_pcm_hw_params_set_rate_near(pcm, hardwareParameters, &rate, 0)) < 0) {
 		terminateSound();
-		sendWarning("Failed to select approximate sample rate. (", snd_strerror(errorCode), ")\n");
+		sendWarning(U"Failed to select approximate sample rate. (", snd_strerror(errorCode), U")\n");
 		return false;
 	}
 	if ((errorCode = snd_pcm_hw_params(pcm, hardwareParameters)) < 0) {
 		terminateSound();
-		sendWarning("Failed to select hardware parameters. (", snd_strerror(errorCode), ")\n");
+		sendWarning(U"Failed to select hardware parameters. (", snd_strerror(errorCode), U")\n");
 		return false;
 	}
 	// Allocate a buffer for sending data to speakers
@@ -112,7 +112,7 @@ bool sound_streamToSpeakers(int channels, int sampleRate, std::function<bool(Saf
 			snd_pcm_prepare(pcm);
 		} else if (errorCode < 0) {
 			terminateSound();
-			throwError("Failed writing data to PCM. (", snd_strerror(errorCode), ")\n");
+			throwError(U"Failed writing data to PCM. (", snd_strerror(errorCode), U")\n");
 		}
 		if (!keepRunning) {
 			break;

+ 3 - 3
Source/tools/builder/code/Machine.cpp

@@ -189,7 +189,7 @@ static void interpretLine(Machine &target, const List<String> &tokens, int64_t s
 				validateSettings(sharedInputFlags, U"in the child after inheriting settings as a build child (build in interpretLine)");
 				argumentsToSettings(sharedInputFlags, tokens, startTokenIndex + 2, endTokenIndex); // Send all tokens after the second token as input arguments to buildProjects.
 				validateSettings(sharedInputFlags, U"in the child after parsing arguments (build in interpretLine)");
-				printText("Building ", second, " from ", fromPath, " which is ", projectPath, "\n");
+				printText(U"Building ", second, U" from ", fromPath, U" which is ", projectPath, U"\n");
 				target.otherProjectPaths.push(projectPath);
 				target.otherProjectSettings.push(sharedInputFlags);
 				validateSettings(target, U"in target after listing a child project\n");
@@ -219,7 +219,7 @@ static void interpretLine(Machine &target, const List<String> &tokens, int64_t s
 					if (validIdentifier(first)) {
 						assignValue(target, first, U"1", false);
 					} else {
-						throwError(U"The token ", first, " is not a valid identifier for implicit assignment to one.\n");
+						throwError(U"The token ", first, U" is not a valid identifier for implicit assignment to one.\n");
 					}
 					validateSettings(target, U"in target after implicitly assigning a value to a variable\n");
 				} else if (string_match(second, U"=")) {
@@ -230,7 +230,7 @@ static void interpretLine(Machine &target, const List<String> &tokens, int64_t s
 					if (validIdentifier(first)) {
 						assignValue(target, first, STRING_EXPR(startTokenIndex + 2, endTokenIndex), false);
 					} else {
-						throwError(U"The token ", first, " is not a valid identifier for assignments.\n");
+						throwError(U"The token ", first, U" is not a valid identifier for assignments.\n");
 					}
 					validateSettings(target, U"in target after explicitly assigning a value to a variable\n");
 				} else {

+ 7 - 9
Source/tools/builder/code/analyzer.cpp

@@ -259,7 +259,6 @@ static void traverserHeaderChecksums(ProjectContext &context, uint64_t &target,
 	for (int64_t h = 0; h < context.dependencies[dependencyIndex].includes.length(); h++) {
 		int64_t includedIndex = context.dependencies[dependencyIndex].includes[h].dependencyIndex;
 		if (!context.dependencies[includedIndex].visited) {
-			//printText(U"	traverserHeaderChecksums(context, ", includedIndex, U") ", context.dependencies[includedIndex].path, "\n");
 			// Bitwise exclusive or is both order independent and entropy preserving for non-repeated content.
 			target = target ^ context.dependencies[includedIndex].contentChecksum;
 			// Just have to make sure that the same checksum is not used twice.
@@ -271,7 +270,6 @@ static void traverserHeaderChecksums(ProjectContext &context, uint64_t &target,
 }
 
 static uint64_t getCombinedChecksum(ProjectContext &context, int64_t dependencyIndex) {
-	//printText(U"getCombinedChecksum(context, ", dependencyIndex, U") ", context.dependencies[dependencyIndex].path, "\n");
 	for (int64_t d = 0; d < context.dependencies.length(); d++) {
 		context.dependencies[d].visited = false;
 	}
@@ -298,9 +296,9 @@ void gatherBuildInstructions(SessionContext &output, ProjectContext &context, Ma
 	// Check if the build system was asked to run the compiler from a specific folder.
 	bool changePath = (string_length(compileFrom) > 0);
 	if (changePath) {
-		printText(U"Using ", compilerName, " as the compiler executed from ", compileFrom, ".\n");
+		printText(U"Using ", compilerName, U" as the compiler executed from ", compileFrom, U".\n");
 	} else {
-		printText(U"Using ", compilerName, " as the compiler from the current directory.\n");
+		printText(U"Using ", compilerName, U" as the compiler from the current directory.\n");
 	}
 	// TODO: Warn if -DNDEBUG, -DDEBUG, or optimization levels are given directly.
 	//       Using the variables instead is both more flexible by accepting input arguments
@@ -340,7 +338,7 @@ void gatherBuildInstructions(SessionContext &output, ProjectContext &context, Ma
 	String generatedCompilerFlags;
 	for (int64_t i = 0; i < settings.compilerFlags.length(); i++) {
 		printText(U"Build script gave compiler flag:", settings.compilerFlags[i], U"\n");
-		string_append(generatedCompilerFlags, " ", settings.compilerFlags[i]);
+		string_append(generatedCompilerFlags, U" ", settings.compilerFlags[i]);
 	}
 	String linkerFlags;
 	for (int64_t i = 0; i < settings.linkerFlags.length(); i++) {
@@ -384,7 +382,7 @@ void gatherBuildInstructions(SessionContext &output, ProjectContext &context, Ma
 		}
 	}
 	if (hasSourceCode) {
-		printText(U"Listing target executable ", programPath, " in the current session.\n");
+		printText(U"Listing target executable ", programPath, U" in the current session.\n");
 		bool executeResult = getFlagAsInteger(settings, U"Supressed") == 0;
 		output.linkerSteps.pushConstruct(compilerName, compileFrom, programPath, settings.linkerFlags, sourceObjectIndices, executeResult);
 	} else {
@@ -414,7 +412,7 @@ void buildProject(SessionContext &output, ReadableString projectFilePath, Machin
 	Machine settings(file_getPathlessName(projectFilePath));
 	inheritMachine(settings, sharedsettings);
 	validateSettings(settings, string_combine(U"in settings after inheriting settings from caller, for ", projectFilePath, U"\n"));
-	printText("Building project at ", projectFilePath, "\n");
+	printText(U"Building project at ", projectFilePath, U"\n");
 	// Check if this project has begun building previously during this session.
 	String absolutePath = file_getAbsolutePath(projectFilePath);
 	for (int64_t p = 0; p < initializedProjects.length(); p++) {
@@ -468,7 +466,7 @@ void buildProject(SessionContext &output, ReadableString projectFilePath, Machin
 
 // Using a folder path and input arguments for all projects.
 void buildProjects(SessionContext &output, ReadableString projectFolderPath, Machine &sharedsettings) {
-	printText("Building all projects in ", projectFolderPath, "\n");
+	printText(U"Building all projects in ", projectFolderPath, U"\n");
 	file_getFolderContent(projectFolderPath, [&sharedsettings, &output](const ReadableString& entryPath, const ReadableString& entryName, EntryType entryType) {
 		if (entryType == EntryType::Folder) {
 			buildProjects(output, entryPath, sharedsettings);
@@ -483,7 +481,7 @@ void buildProjects(SessionContext &output, ReadableString projectFolderPath, Mac
 
 void build(SessionContext &output, ReadableString projectPath, Machine &sharedsettings) {
 	EntryType entryType = file_getEntryType(projectPath);
-	printText("Building anything at ", projectPath, " which is ", entryType, "\n");
+	printText(U"Building anything at ", projectPath, U" which is ", entryType, U"\n");
 	if (entryType == EntryType::File) {
 		String extension = string_upperCase(file_getExtension(projectPath));
 		if (!string_match(extension, U"DSRPROJ")) {

+ 6 - 6
Source/tools/builder/code/generator.cpp

@@ -26,16 +26,16 @@ static void produce_setCompilationFolder(String &generatedCode, ScriptLanguage l
 		if (!string_match(previousPath, newPath)) {
 			if (string_length(previousPath) > 0) {
 				if (language == ScriptLanguage::Batch) {
-					string_append(generatedCode,  "popd\n");
+					string_append(generatedCode, U"popd\n");
 				} else if (language == ScriptLanguage::Bash) {
 					string_append(generatedCode, U")\n");
 				}
 			}
 			if (string_length(newPath) > 0) {
 				if (language == ScriptLanguage::Batch) {
-					string_append(generatedCode,  "pushd ", newPath, "\n");
+					string_append(generatedCode, U"pushd ", newPath, U"\n");
 				} else if (language == ScriptLanguage::Bash) {
-					string_append(generatedCode, U"(cd ", newPath, ";\n");
+					string_append(generatedCode, U"(cd ", newPath, U";\n");
 				}
 			}
 		}
@@ -154,7 +154,7 @@ void produce(SessionContext &input, const ReadableString &scriptPath, ScriptLang
 			produce_printMessage<GENERATE>(generatedCode, language, string_combine(U"Compiling ", sourceObject->sourcePath, U" ID:", sourceObject->identityChecksum, U"."));
 			produce_callProgram<GENERATE>(generatedCode, language, sourceObject->compilerName, compilationArguments);
 			if (language == ScriptLanguage::Batch) {
-				string_append(generatedCode,  ")\n");
+				string_append(generatedCode,  U")\n");
 			} else if (language == ScriptLanguage::Bash) {
 				string_append(generatedCode, U"fi\n");
 			}
@@ -192,7 +192,7 @@ void produce(SessionContext &input, const ReadableString &scriptPath, ScriptLang
 		String linkerFlags;
 		for (int64_t l = 0; l < linkingStep->linkerFlags.length(); l++) {
 			String linkerFlag = linkingStep->linkerFlags[l];
-			string_append(linkerFlags, " ", linkerFlag);
+			string_append(linkerFlags, U" ", linkerFlag);
 			linkerArguments.push(linkerFlag);
 			printText(U"\t\t* ", linkerFlag, U" library\n");
 		}
@@ -215,7 +215,7 @@ void produce(SessionContext &input, const ReadableString &scriptPath, ScriptLang
 	produce_printMessage<GENERATE>(generatedCode, language, U"Done building.");
 
 	if (GENERATE) {
-		printText(U"Saving script to ", scriptPath, "\n");
+		printText(U"Saving script to ", scriptPath, U"\n");
 		if (language == ScriptLanguage::Batch) {
 			// Batch on MS-Windows can not recognize a Byte Order Mark, so just encode it as Latin 1.
 			string_save(scriptPath, generatedCode, CharacterEncoding::Raw_Latin1, LineEncoding::CrLf);