Address Gitlib issu #57: Resume can't open save file...
authorEric S. Raymond <esr@thyrsus.com>
Mon, 4 Apr 2022 21:51:06 +0000 (17:51 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 4 Apr 2022 21:51:06 +0000 (17:51 -0400)
...when auto-completed filename is followed by a space character.

saveresume.c

index 783e6714262b8857b487bec49a4cdbaf2b0b97a0..15d14c1472dbbdc09b784581ee30f9e3c9fd1d80 100644 (file)
@@ -108,6 +108,9 @@ int resume(void)
 
     while (fp == NULL) {
         char* name = readline("\nFile name: ");
+       // Autocomplete can leave the input with an extra traoling space.
+       if (name != NULL && strlen(name) > 0 && name[strlen(name) - 1] == ' ')
+           name[strlen(name) - 1] = '\0';
         if (name == NULL)
             return GO_TOP;
         fp = fopen(name, READ_MODE);