@@ -76,7 +76,9 @@ FILE *openConfig(const char *flags, bool debug) {
7676int nextInteger (FILE *fp, int def) {
7777 int result = 0 ;
7878 for (int c = fgetc (fp); c != EOF && c != ' ,' && c != ' \n ' ; c = fgetc (fp)) {
79- result = (result * 10 ) + (c - ' 0' );
79+ if (c != ' \r ' ) {
80+ result = (result * 10 ) + (c - ' 0' );
81+ }
8082 }
8183 if (!result) {
8284 result = def;
@@ -90,8 +92,10 @@ int nextInteger(FILE *fp, int def) {
9092int nextHex (FILE *fp, int def) {
9193 int result = 0 ;
9294 for (int c = fgetc (fp); c != EOF && c != ' ,' && c != ' \n ' ; c = fgetc (fp)) {
93- int val = (c >= ' a' ) ? (10 + (c - ' a' )) : (c - ' 0' );
94- result = (result * 16 ) + val;
95+ if (c != ' \r ' ) {
96+ int val = (c >= ' a' ) ? (10 + (c - ' a' )) : (c - ' 0' );
97+ result = (result * 16 ) + val;
98+ }
9599 }
96100 if (!result) {
97101 result = def;
@@ -106,7 +110,7 @@ int nextString(FILE *fp) {
106110 int pos = ftell (fp);
107111 int len = 0 ;
108112 for (int c = fgetc (fp); c != EOF; c = fgetc (fp)) {
109- if (c == ' \n ' ) {
113+ if (c == ' \n ' || c == ' \r ' ) {
110114 if (len > 0 ) {
111115 // string terminator
112116 break ;
@@ -140,7 +144,7 @@ void restorePath(FILE *fp, bool restoreDir) {
140144// restore window position
141145//
142146void restoreSettings (SDL_Rect &rect, int &fontScale, bool debug, bool restoreDir) {
143- FILE *fp = openConfig (" r " , debug);
147+ FILE *fp = openConfig (" rb " , debug);
144148 if (fp) {
145149 rect.x = nextInteger (fp, SDL_WINDOWPOS_UNDEFINED);
146150 rect.y = nextInteger (fp, SDL_WINDOWPOS_UNDEFINED);
@@ -182,7 +186,7 @@ void restoreSettings(SDL_Rect &rect, int &fontScale, bool debug, bool restoreDir
182186// save the window position
183187//
184188void saveSettings (SDL_Window *window, int fontScale, bool debug) {
185- FILE *fp = openConfig (" w " , debug);
189+ FILE *fp = openConfig (" wb " , debug);
186190 if (fp) {
187191 int x, y, w, h;
188192 SDL_GetWindowPosition (window, &x, &y);
@@ -229,9 +233,12 @@ bool getRecentFile(String &path, unsigned position) {
229233 return result;
230234}
231235
232- void getRecentFileList (String &fileList) {
236+ void getRecentFileList (String &fileList, String ¤t ) {
233237 for (int i = 0 ; i < NUM_RECENT_ITEMS; i++) {
234238 if (recentPath[i].length () > 0 ) {
239+ if (recentPath[i].equals (current)) {
240+ fileList.append (" >> " );
241+ }
235242 fileList.append (i + 1 ).append (" " );
236243 fileList.append (recentPath[i]).append (" \n\n " );
237244 }
0 commit comments