MCPcopy Index your code
hub / github.com/microsoft/vscode-cpptools / legacyExtractArgs

Function legacyExtractArgs

Extension/src/common.ts:963–1007  ·  view source on GitHub ↗
(argsString: string)

Source from the content-addressed store, hash-verified

961}
962
963function legacyExtractArgs(argsString: string): string[] {
964 const result: string[] = [];
965 let currentArg: string = "";
966 let isWithinDoubleQuote: boolean = false;
967 let isWithinSingleQuote: boolean = false;
968 for (let i: number = 0; i < argsString.length; i++) {
969 const c: string = argsString[i];
970 if (c === '\\') {
971 currentArg += c;
972 if (++i === argsString.length) {
973 if (currentArg !== "") {
974 result.push(currentArg);
975 }
976 return result;
977 }
978 currentArg += argsString[i];
979 continue;
980 }
981 if (c === '"') {
982 if (!isWithinSingleQuote) {
983 isWithinDoubleQuote = !isWithinDoubleQuote;
984 }
985 } else if (c === '\'') {
986 // On Windows, a single quote string is not allowed to join multiple args into a single arg
987 if (!isWindows) {
988 if (!isWithinDoubleQuote) {
989 isWithinSingleQuote = !isWithinSingleQuote;
990 }
991 }
992 } else if (c === ' ') {
993 if (!isWithinDoubleQuote && !isWithinSingleQuote) {
994 if (currentArg !== "") {
995 result.push(currentArg);
996 currentArg = "";
997 }
998 continue;
999 }
1000 }
1001 currentArg += c;
1002 }
1003 if (currentArg !== "") {
1004 result.push(currentArg);
1005 }
1006 return result;
1007}
1008
1009function extractArgs(argsString: string): string[] {
1010 argsString = argsString.trim();

Callers 1

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected