@@ -874,21 +874,23 @@ void AnycubicTouchscreenClass::RenderCurrentFolder(uint16_t selectedNumber) {
874
874
SERIAL_ECHOLN (currentFileList.filename ());
875
875
#endif
876
876
877
- const char * fileName = currentFileList.filename ();
877
+ const char * fileName = currentFileList.filename ();
878
878
unsigned int fileNameLen = strlen (fileName);
879
879
880
- // Cut off too long filenames.
881
- // They don't fit on the screen anyway.
882
- #if ENABLED(KNUTWURST_DGUS2_TFT)
883
- bool fileNameWasCut = false ;
884
- if (fileNameLen >= MAX_PRINTABLE_FILENAME_LEN) {
885
- fileNameWasCut = true ;
886
- fileNameLen = MAX_PRINTABLE_FILENAME_LEN;
887
- }
888
- #endif
880
+ // Cut off too long filenames.
881
+ // They don't fit on the screen anyway.
882
+ #if ENABLED(KNUTWURST_DGUS2_TFT)
883
+ bool fileNameWasCut = false ;
884
+ if (fileNameLen >= MAX_PRINTABLE_FILENAME_LEN) {
885
+ fileNameWasCut = true ;
886
+ fileNameLen = MAX_PRINTABLE_FILENAME_LEN;
887
+ }
888
+ static char outputString[MAX_PRINTABLE_FILENAME_LEN];
889
+ #else
890
+ char outputString[fileNameLen];
891
+ #endif
889
892
890
893
// Bugfix for non-printable special characters which are now replaced by underscores.
891
- static char outputString[MAX_PRINTABLE_FILENAME_LEN] = {' \0 ' };
892
894
for (unsigned int i = 0 ; i <= fileNameLen; i++) {
893
895
if (isPrintable (fileName[i])) {
894
896
outputString[i] = fileName[i];
@@ -929,7 +931,7 @@ void AnycubicTouchscreenClass::RenderCurrentFolder(uint16_t selectedNumber) {
929
931
outputString[MAX_PRINTABLE_FILENAME_LEN] = ' \0 ' ;
930
932
}
931
933
#else
932
- outputString[fileNameLen] = ' \0 ' ;
934
+ outputString[fileNameLen] = ' \0 ' ;
933
935
#endif
934
936
935
937
0 commit comments