X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Ffile-handle.q;h=6b155027f68b196778a46c89b84dcee58b92caf1;hb=dc4eb33f68d5eebae670115752d3994f4f3d5c41;hp=5c48007912c84029b09e0973ef3575750b1746d1;hpb=7dc203206d3f3172474a4ec0f4dcab5364f4ce26;p=pspp diff --git a/src/file-handle.q b/src/file-handle.q index 5c48007912..6b155027f6 100644 --- a/src/file-handle.q +++ b/src/file-handle.q @@ -14,8 +14,8 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. */ #include #include "file-handle.h" @@ -73,7 +73,7 @@ get_handle_with_name (const char *handle_name) struct file_handle *iter; for (iter = file_handles; iter != NULL; iter = iter->next) - if (!strcmp (handle_name, iter->name)) + if (!strcasecmp (handle_name, iter->name)) return iter; return NULL; } @@ -109,22 +109,21 @@ get_handle_for_filename (const char *filename) int cmd_file_handle (void) { - char handle_name[9]; + char handle_name[LONG_NAME_LEN + 1]; struct cmd_file_handle cmd; struct file_handle *handle; if (!lex_force_id ()) return CMD_FAILURE; - strcpy (handle_name, tokid); + str_copy_trunc (handle_name, sizeof handle_name, tokid); handle = get_handle_with_name (handle_name); if (handle != NULL) { - msg (SE, _("File handle %s already refers to " - "file %s. File handle cannot be redefined within a " - "session."), - tokid, handle->filename); + msg (SE, _("File handle %s already refers to file %s. " + "File handles cannot be redefined within a session."), + handle_name, handle->filename); return CMD_FAILURE; } @@ -236,7 +235,7 @@ mode_name (const char *mode) } -/* Tries to open FILE with the given TYPE and MODE. +/* Tries to open handle H with the given TYPE and MODE. TYPE is the sort of file, e.g. "system file". Only one given type of access is allowed on a given file handle at once. @@ -392,8 +391,7 @@ handle_get_mode (const struct file_handle *handle) return handle->mode; } -/* Returns the width of a logical record on HANDLE. Applicable - only to MODE_BINARY files. */ +/* Returns the width of a logical record on HANDLE. */ size_t handle_get_record_width (const struct file_handle *handle) { @@ -421,10 +419,11 @@ fh_init(void) void fh_done(void) { - assert(handle_list); - - ll_destroy(handle_list); - handle_list = 0; + if ( handle_list ) + { + ll_destroy(handle_list); + handle_list = 0; + } }