Fixed some error messages and a small bug in list.gib

This commit is contained in:
Brian Koropoff 2002-06-11 06:08:31 +00:00
parent f39e53b859
commit fe48995a0c
2 changed files with 8 additions and 7 deletions

View file

@ -100,7 +100,7 @@ alias list_find { // Returns the index of a string in a list
return 0;
}
// This is an evil for statement. You have been warned.
for {if #{$argn > 2} {i = $2} else {i = 1}; #{$i<=~{list_get $1 size}}; i = #{$i+1}} {
for {if #{$argn > 3} {i = $2} else {i = 1}; #{$i<=~{list_get $1 size}}; i = #{$i+1}} {
if ~{streq $2 ~{list_get $1 $i}} {
return $i;
};

View file

@ -2333,7 +2333,8 @@ Cmd_CollapsePath (char *str)
}
if ( (!path[0])
|| (path[0] == '.' && path[1] == '.' && (path[2] == '/' || path [2] == 0))
|| (path[strlen (path) - 1] =='/') ) {
|| (path[strlen (path) - 1] =='/')
|| path[0] == '~') {
return 0;
}
return 1;
@ -2345,24 +2346,24 @@ Cmd_File_write_f (void)
char *path;
if (Cmd_Restricted ()) {
Cmd_Error ("writefile: access to restricted command denied.\n");
Cmd_Error ("file_write: access to restricted command denied.\n");
return;
}
if (Cmd_Argc() != 3) {
Cmd_Error ("writefile: invalid number of arguments.\n");
Cmd_Error ("file_write: invalid number of arguments.\n");
return;
}
path = strdup (Cmd_Argv(1));
SYS_CHECKMEM (path);
if (!Cmd_CollapsePath (path)) {
free (path);
Cmd_Error ("writefile: access to restricted directory/file denied.\n");
Cmd_Error ("file_write: access to restricted directory/file denied.\n");
return;
}
free(path);
Sys_DPrintf ("writefile: opening %s/%s\n", com_gamedir, path);
Sys_DPrintf ("file_write: opening %s/%s\n", com_gamedir, path);
if (!(file = Qopen (va("%s/%s", com_gamedir, Cmd_Argv(1)), "w"))) {
Cmd_Error (va ("writefile: could not open file for writing: %s\n", strerror (errno)));
Cmd_Error (va ("file_write: could not open file for writing: %s\n", strerror (errno)));
return;
}
Qprintf (file, "%s", Cmd_Argv(2));