Updated interpreters
[projects/chimara/chimara.git] / interpreters / frotz / files.c
index 6ed8c3371a67e5897680a7e5c95c9dda90f41059..f40739593b664e8f6ddb7f097a4f4981d1e79d1a 100644 (file)
@@ -46,30 +46,21 @@ static FILE *pfp = NULL;
  * the old transscription file in V1 to V4, and to ask for a new file
  * name in V5+.
  *
- * Alas, we cannot do this, since glk cannot give us the filename
- * to reopen it again, and I dont want to mess with filerefs here.
- *
  */
 
+static bool script_valid = FALSE;
+
 void script_open (void)
 {
-       static bool script_valid = FALSE;
 
        h_flags &= ~SCRIPTING_FLAG;
 
-#if 0
-       if (h_version >= V5 || !script_valid) {
-               if (!os_read_file_name (new_name, script_name, FILE_SCRIPT))
-                       goto done;
-       }
-
-       /* Opening in "at" mode doesn't work for script_erase_input... */
-
-       if ((sfp = fopen (sfp = fopen (script_name, "r+t")) != NULL || (sfp = fopen (script_name, "w+t")) != NULL) {
-
-#endif
+       if (h_version < V5 && script_valid)
+               sfp = frotzreopen(FILE_SCRIPT);
+       else
+               sfp = frotzopenprompt(FILE_SCRIPT);
 
-       if ((sfp = frotzopenprompt(FILE_SCRIPT)) != NULL)
+       if (sfp != NULL)
        {
                fseek (sfp, 0, SEEK_END);
 
@@ -82,8 +73,6 @@ void script_open (void)
 
        } else print_string ("Cannot open file\n");
 
-/* done: */
-
        SET_WORD (H_FLAGS, h_flags)
 
 }/* script_open */
@@ -140,7 +129,7 @@ void script_char (zchar c)
        if (c == ZC_GAP)
        { script_char (' '); script_char (' '); return; }
 
-       fputc (c, sfp); script_width++;
+       fputwc (c, sfp); script_width++;
 
 }/* script_char */
 
@@ -170,7 +159,7 @@ void script_word (const zchar *s)
                else
                        width += 1;
 
-       if (f_setup.script_cols != 0 && script_width + width > f_setup.script_cols) {
+       if (option_script_cols != 0 && script_width + width > option_script_cols) {
 
                if (*s == ' ' || *s == ZC_INDENT || *s == ZC_GAP)
                        s++;
@@ -203,7 +192,7 @@ void script_write_input (const zchar *buf, zchar key)
        for (i = 0, width = 0; buf[i] != 0; i++)
                width++;
 
-       if (f_setup.script_cols != 0 && script_width + width > f_setup.script_cols)
+       if (option_script_cols != 0 && script_width + width > option_script_cols)
                script_new_line ();
 
        for (i = 0; buf[i] != 0; i++)