Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion app/src/processing/app/Sketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,7 @@ public void handleAddFile() {

if (result) {
// editor.statusNotice("One file added to the sketch.");
//Done from within TaskAddFile inner class when copying is completed
//Done from within TaskAddFile inner class when copying is completed
}
}

Expand Down Expand Up @@ -1720,6 +1720,43 @@ static final boolean asciiLetter(char c) {
static public String sanitizeName(String origName) {
char orig[] = origName.toCharArray();
StringBuilder sb = new StringBuilder();
boolean keywordFlag = false;

// Opening the reservedKeywords.txt file to be check if the 'origName'
// is a 'Reserved Keyword' in Processing or class Name or primitive.
String keywordFileName = "lib/reservedKeywords.txt";
File keywordFile = new File(keywordFileName);

try {
FileReader fileReader = new FileReader(keywordFile);
BufferedReader bufferedReader = new BufferedReader(fileReader);

String keyword;

while ((keyword = bufferedReader.readLine()) != null) {

if (origName.equalsIgnoreCase(keyword) == true) {
keywordFlag = true;
break;
}
}
}
catch (FileNotFoundException ex) {
System.out.println("File not found!");
}
catch(IOException ex) {
System.out.println("IOException");
}

// If 'origName' is found in the 'reservedKeywords.txt' file
// Pop up a Warning message
if (keywordFlag == true) {
Messages.showWarning(Language.text("check_name.messages.is_reserved_keyword"),
Language.interpolate("check_name.messages.is_reserved_keyword.description", origName));
return "bad_sketch_name_please_fix";
}



// Can't lead with a digit (or anything besides a letter), so prefix with
// "sketch_". In 1.x this prefixed with an underscore, but those get shaved
Expand Down
2 changes: 2 additions & 0 deletions build/shared/lib/languages/PDE.properties
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ ensure_exist.messages.unrecoverable.description = Could not properly re-save the

# Check name
check_name.messages.is_name_modified = The sketch name had to be modified. Sketch names can only consist\nof ASCII characters and numbers (but cannot start with a number).\nThey should also be less than 64 characters long.
check_name.messages.is_reserved_keyword = Invalid name
check_name.messages.is_reserved_keyword.description = Name '%s' is a not allowed(reserved keyword), \nplease 'Save As' with another name.

# ---------------------------------------
# Contributions
Expand Down
Loading